XL1200-EMU Symbolics XL1200 Emulator

Volume 2: Ivory Instruction Set Architecture & Execution Semantics

This volume specifies Ivory's instruction stream encoding, packed halfword and fullword formats, the complete 8-bit opcode table (#o000..#o377), function call/entry/return conventions, arithmetic and Weitek W3x64 FPA execution rules, and hardware trap dispatch semantics.

All encodings and microstate constants match ivory_hw.h and the from-scratch C11 execution units in emu/src/{cpu.c,cpu_decode.c,isa_call.c,isa_stack.c,isa_arith.c,isa_lisp.c,isa_sys.c,fpa_w3x64.c}.

Primary Reference Sources (local-only when present):

  • genera-original/sys.sct/i-sys/opdef.lisp — Canonical 8-bit opcode assignments (DEFOPCODE).
  • genera-original/sys.sct/i-compiler/{i-instruction-set.lisp,i-back-end.lisp,disassemble.lisp} — Halfword formats, entry words, and FINISH-CALL-N encoding.
  • genera-original/sys.sct/sys/iarithdefs.lisp — -NO-POP binary arithmetic predicate trap contract.
  • genera-original/sys.sct/debugger/{itrap-dispatch.lisp,itrap-defs.lisp} — Rev 4 / Rev 4A *TRAP-DISPATCH-TABLE*.
  • I_Machine/I-Machine_Architecture_Specification.pdf — Chapters 6–9 (Instructions, Calling Convention, Traps).

1. Instruction Stream & Sequencing Rules

Every 40-bit word fetched from the instruction stream is classified by its 2-bit sequence code (<39:38>, IvoryInstructionSequenceCode) and 6-bit Data Type (<37:32>):

  1. Sequencing Fence (seq_code == 1, IVORY_SEQ_FENCE):
    • Marks non-executable function trailers / debug info. Attempting to execute at either Even or Odd phase raises IVORY_TRAP_ERROR with IVORY_REV4_USTATE_I_STAGE_ERROR (0x011E).
  2. Packed Halfword Pair (DTP in #o60..#o77, (dtp & #o60) == #o60):
    • Packs two 18-bit instructions into bits <35:0>:
      • Even halfword (DTP_EVEN_PC): bits <17:0>.
      • Odd halfword (DTP_ODD_PC): bits <35:18> (its top 4 bits <35:32> occupy the low 4 bits of the 6-bit DTP!).
    • Sequential PC advancement depends on seq_code (expressed as halfword slot stride):
      • 0 (IVORY_SEQ_PC_PLUS_1): Even +1 (-> Odd same word), Odd +1 (-> Even next word).
      • 2 (IVORY_SEQ_PC_MINUS_1): Even -1, Odd -1 (steps backwards by 1 halfword).
      • 3 (IVORY_SEQ_PC_EVEN_2_ODD_3, CDR-JUMP): Even +2 (-> Even next word, skipping Odd), Odd +3 (-> Even word +2).
  3. Fullword Instructions (DTP < #o60, Even phase only):
    • Executing any non-packed word at DTP_ODD_PC raises IVORY_TRAP_ERROR with IVORY_REV4_USTATE_I_STAGE_ERROR (0x011E).
    • Sequential stride is +2 halfwords (next word, Even phase), or -1 if seq_code == 2.
    • Subclasses:
      • Fullword Call Starters (#o50..#o57): StartCall instructions (DTP_CALL_COMPILED_EVEN, ODD, INDIRECT, GENERIC, and their +4 prefetch variants). They open a call frame, load CONTINUATION, set CR.call_started = 1, and advance sequentially so caller code can push arguments before FinishCall.
      • DTP_EXTERNAL_VALUE_CELL_POINTER (#o04): Reads the cell at word.pointer via IVORY_MEM_DATA_READ (following invisible forwarding pointers and GC read barriers) and pushes the result onto TOS.
      • Inline Fullword Constants (ivory_is_fullword_constant): Valid Lisp values (FIXNUM, SINGLE_FLOAT, NIL, LIST, SYMBOL, ARRAY, STRING, CHARACTER, COMPILED_FUNCTION, etc.) are pushed directly onto TOS with CDR_NEXT.
      • Illegal Fullword Tags (ivory_is_fullword_illegal: NULL, MONITOR_FORWARD, HEADER_P, HEADER_I, ONE_Q_FORWARD, HEADER_FORWARD, ELEMENT_FORWARD, BOUND_LOCATION, LOGIC_VARIABLE, GC_FORWARD): Raise IVORY_TRAP_ERROR with IVORY_REV4_USTATE_ILLEGAL_FULLWORD_INSTR (0x0000).

2. 18-Bit Halfword Formats & Function Entry Words

Format 1: Stack / Address Operand (IvoryHalfwordInstr.stack_op)

 17        10  9   8  7              0
+------------+------+-----------------+
|  Opcode    | Mode |  8-Bit Offset   |
|  (8 bits)  |(2 b) |    (8 bits)     |
+------------+------+-----------------+
ModeConstantValue Operand (ivory_cpu_resolve_operand)Address Operand (ivory_cpu_resolve_address)
00IVORY_ADDR_FPRead stack word at FP + offsetLocative FP + offset
01IVORY_ADDR_LPRead stack word at LP + offsetLocative LP + offset
10IVORY_ADDR_SPoffset == 0: SP-pop (pop TOS); else read SP + offset - 255offset == 0: illegal (I_STAGE_ERROR); else SP + offset - 255
11IVORY_ADDR_IMMEDIATE8-bit immediate fixnum (signed or unsigned per opcode)Illegal (I_STAGE_ERROR)

Format 2: 10-Bit Immediate / Signed Branch Offset (IvoryHalfwordInstr.immed10_op)

 17        10  9                     0
+------------+------------------------+
|  Opcode    |   10-Bit Immediate     |
|  (8 bits)  |  (or Signed Branch Δ)  |
+------------+------------------------+

Used by branches (#o060..#o077, #o174, #o175, #o375 — signed 10-bit halfword delta relative to current PC), TYPE-MEMBER (#o040..#o047 — 12-bit mask across opcode low 2 bits + 10-bit imm), FINISH-CALL-* (#o134..#o137), MEMORY-READ (#o116..#o117), READ/WRITE-INTERNAL-REGISTER (#o154..#o155), COPROCESSOR-READ/WRITE (#o156..#o157), and LDB/DPB (#o170..#o173, #o370..#o373).

Format 3: Full 36-Bit Function Entry Instruction (#o176 / #o177)

Function entry points always reside at an Even halfword and consume the entire 36-bit packed word (IvoryWord.entry_instr, sysdef.lisp:763-774):

 39 38 37 36 35  32 31  28  27  26  25      18 17      10  9  8 7        0
+-----+-----+------+------+---+---+-----------+----------+-----+----------+
| Seq | 11  | Odd  |  SW  |Int|Inh|  max_args |  Opcode  | 11  | min_args |
|(2b) |(2b) | Top  |Flags |Fn |Lnk|  (+2, 8b) | #o176/177|(2b) | (+2, 8b) |
+-----+-----+------+------+---+---+-----------+----------+-----+----------+
  • #o176 (OP_ENTRY_REST_ACCEPTED): Accepts excess arguments beyond max_args as a &rest list.
  • #o177 (OP_ENTRY_REST_NOT_ACCEPTED): Rejects nargs > max_args with IVORY_REV4_USTATE_TOO_MANY_ARGUMENTS (0x0613).
  • Both min_args (<7:0>) and max_args (<25:18>) are biased by +2 (accounting for the 2-word frame header). Receiving fewer than min_args traps with IVORY_REV4_USTATE_TOO_FEW_ARGUMENTS (0x0034).
  • Entry words normally carry CDR-JUMP (seq_code = 3) so execution advances directly to PC + 1 Even, skipping the upper halfword's max_args/flag metadata.

3. Complete Verified 8-Bit Opcode Table (#o000..#o377)

Matches IvoryOpcode in ivory_hw.h and k_implemented_opcode[256] in emu/src/cpu_decode.c (219 implemented opcodes; unlisted slots decode to HANDLER_TRAP_UNIMP_OPCODE, post-trapping to IVORY_TRAP_INSTR_EXCEPTION_BASE + opcode):

Octal RangeMnemonics
#o000..#o007CAR, CDR, ENDP, SETUP-1D-ARRAY, SETUP-FORCE-1D-ARRAY, BIND-LOCATIVE, RESTORE-BINDING-STACK, EPHEMERALP
#o010..#o015START-CALL, JUMP, TAG, DEREFERENCE, LOGIC-TAIL-TEST, %PROC-BREAKPOINT
#o020..#o027PUSH-LEXICAL-VAR-0..7
#o030..#o036BLOCK-0..3-WRITE, ZEROP, MINUSP, PLUSP
#o040..#o047TYPE-MEMBER-0..3, TYPE-MEMBER-NO-POP-0..3
#o050..#o057LOCATE-LOCALS, CATCH-CLOSE, GENERIC-DISPATCH, MESSAGE-DISPATCH, CHECK-PREEMPT-REQUEST, PUSH-GLOBAL-LOGIC-VARIABLE, NO-OP, HALT
#o060..#o067BRANCH-TRUE family (8 pop/no-pop/extra-pop variants)
#o070..#o077BRANCH-FALSE family (8 pop/no-pop/extra-pop variants)
#o100..#o107PUSH, PUSH-N-NILS, PUSH-ADDRESS-SP-RELATIVE, PUSH-LOCAL-LOGIC-VARIABLES, RETURN-MULTIPLE, RETURN-KLUDGE, TAKE-VALUES, UNBIND-N
#o110..#o117PUSH-{,ADDRESS-}INSTANCE-VARIABLE{,-ORDERED}, UNARY-MINUS, RETURN-SINGLE, MEMORY-READ, MEMORY-READ-ADDRESS
#o120..#o133BLOCK-0..3-READ, BLOCK-0..3-READ-SHIFT, BLOCK-0..3-READ-TEST
#o134..#o137FINISH-CALL-N, FINISH-CALL-N-APPLY, FINISH-CALL-TOS, FINISH-CALL-TOS-APPLY
#o140..#o147SET-TO-CAR, SET-TO-CDR, SET-TO-CDR-PUSH-CAR, INCREMENT, DECREMENT, POINTER-INCREMENT, SET-CDR-CODE-1, SET-CDR-CODE-2
#o150..#o157PUSH-ADDRESS, SET-SP-TO-ADDRESS, SET-SP-TO-ADDRESS-SAVE-TOS, READ-INTERNAL-REGISTER, WRITE-INTERNAL-REGISTER, COPROCESSOR-READ, COPROCESSOR-WRITE
#o160..#o163BLOCK-0..3-READ-ALU
#o170..#o177LDB, CHAR-LDB, P-LDB, P-TAG-LDB, BRANCH, LOOP-DECREMENT-TOS, ENTRY-REST-ACCEPTED, ENTRY-REST-NOT-ACCEPTED
#o200..#o217RPLACA, RPLACD, MULTIPLY, QUOTIENT, CEILING, FLOOR, TRUNCATE, ROUND, REMAINDER, RATIONAL-QUOTIENT, MIN, MAX, ALU, LOGAND, LOGXOR, LOGIOR
#o220..#o237ROT, LSH, MULTIPLY-DOUBLE, LSHC-BIGNUM-STEP, STACK-BLT, RGETF, MEMBER, ASSOC, POINTER-PLUS, POINTER-DIFFERENCE, ASH, STORE-CONDITIONAL, MEMORY-WRITE, P-STORE-CONTENTS, BIND-LOCATIVE-TO-VALUE, UNIFY
#o240..#o257POP-LEXICAL-VAR-0..7, MOVEM-LEXICAL-VAR-0..7
#o260..#o267EQUAL-NUMBER, LESSP, GREATERP, EQL, EQUAL-NUMBER-NO-POP, LESSP-NO-POP, GREATERP-NO-POP, EQL-NO-POP
#o270..#o277EQ (#o270), LOGTEST (#o273), EQ-NO-POP (#o274), LOGTEST-NO-POP (#o277)
#o300..#o307ADD, SUB, 32-BIT-PLUS, 32-BIT-DIFFERENCE, ADD-BIGNUM-STEP, SUB-BIGNUM-STEP, MULTIPLY-BIGNUM-STEP, DIVIDE-BIGNUM-STEP
#o310..#o317ASET-1, ALLOCATE-LIST-BLOCK, AREF-1, ALOC-1, STORE-ARRAY-LEADER, ALLOCATE-STRUCTURE-BLOCK, ARRAY-LEADER, ALOC-LEADER
#o320..#o327POP/MOVEM-INSTANCE-VARIABLE{,-ORDERED}, INSTANCE-REF, INSTANCE-SET, INSTANCE-LOC, SET-TAG
#o331, #o335UNSIGNED-LESSP, UNSIGNED-LESSP-NO-POP
#o340..#o342POP, MOVEM, MERGE-CDR-NO-POP
#o350..#o352FAST-AREF-1, FAST-ASET-1, STACK-BLT-ADDRESS
#o370..#o373DPB, CHAR-DPB, P-DPB, P-TAG-DPB
#o375..#o377LOOP-INCREMENT-TOS-LESS-THAN, CATCH-OPEN, %HACK (%halt)

4. Calling Convention, Closures & Frame Lifecycle (isa_call.c)

  1. StartCall (Fullword #o50..#o57 or Packed #o010):
    • Pushes the 2-word frame header onto the stack: [saved CONTINUATION, saved CR] (setting saved CR.call_started = old, saved CR.value_disposition from the call).
    • Resolves the callee target:
      • DTP_COMPILED_FUNCTION / DTP_EVEN_PC / DTP_ODD_PC: loads entry PC into CONTINUATION.
      • DTP_LEXICAL_CLOSURE (#o32): reads [env, fn], pushes env as an extra argument right after the frame header, sets CR.extra_argument = 1, and resolves fn into CONTINUATION.
      • DTP_SYMBOL (#o30): dereferences the symbol's function cell (symbol + 2) via DATA_READ.
      • DTP_GENERIC_FUNCTION (#o35) or non-compiled objects: dispatches via IVORY_TRAP_INTERPRETER_FN_BASE + dtp (#o4400 + dtp) or generic dispatch.
    • Sets CR.call_started = 1 and advances PC sequentially so arguments can be pushed.
  2. FinishCall (#o134..#o137):
    • Critical encoding invariant: For FINISH-CALL-N (#o134) and FINISH-CALL-N-APPLY (#o135), bits <7:0> encode n_args + 1 (0 arguments -> 1, 2 arguments -> 3), and bits <9:8> encode value_disposition (EFFECT, VALUE, RETURN, MULTIPLE).
    • Computes new_fp = SP - n_args - (extra_argument ? 1 : 0) - 1, sets LP = SP + 1, records caller_frame_size = new_fp - old_fp and argument_size = LP - new_fp, transfers CONTINUATION -> PC, and saves the return PC into CONTINUATION.
  3. Entry (#o176 / #o177):
    • Validates argument_size against min_args and max_args (both +2), handles CR.apply via PULL-APPLY-ARGS, builds a &rest list if #o176 with excess args, and initializes LP.
  4. Return (RETURN-SINGLE #o115, RETURN-MULTIPLE #o104, RETURN-KLUDGE #o105):
    • Checks CR.trap_on_exit (0x04C9), CR.cleanup_catch (#o5127), and CR.cleanup_bindings (#o5126) before unwinding.
    • Delivers return values according to CR.value_disposition (EFFECT discards, VALUE pushes 1 value, MULTIPLE pushes N values + fixnum count, RETURN propagates directly to grandparent frame) and restores FP, LP, CR, and PC.

5. Arithmetic, -NO-POP Predicates & Weitek W3x64 FPA Execution

  • Fixnum & Single-Float Fast Paths (isa_arith.c):
    • Same-tag DTP_FIXNUM arithmetic executes natively in 32-bit signed arithmetic; 32-bit signed overflow or mixed/non-fixnum operands post-trap to IVORY_TRAP_ARITH_EXCEPTION_BASE + ((op & #o37) << 6) | ((dtp1 & 7) << 3) | (dtp2 & 7).
    • DTP_SINGLE_FLOAT fast paths in isa_arith.c route through ivory_fpa_exec_single_op() (emu/src/fpa_w3x64.c) so rounding modes (SR0<2:1>) and exception traps (SR2) match the W3x64 hardware coprocessor exactly.
  • -NO-POP Binary Predicate Trap Contract (iarithdefs.lisp:221-252, isa_stack.c):
    • EQUAL-NUMBER-NO-POP (#o264), LESSP-NO-POP (#o265), GREATERP-NO-POP (#o266), EQL-NO-POP (#o267), LOGTEST-NO-POP (#o277), and UNSIGNED-LESSP-NO-POP (#o335) normally keep arg1 on the stack and push the boolean result above it.
    • When an operand type forces an arithmetic post-trap, Genera's software handler returns (VALUES arg1 result) (2 values). Hardware therefore pops arg1 before pushing the trap frame (take_pred_arith_trap2) so returning 2 values overwrites arg1 and pushes result without shifting SP by +1.
  • Weitek W3x64 Coprocessor Execution Sequence (fpa_w3x64.c):
    1. Software stages R0_HI (#o0000) / R0_LO (#o0002) and R1_LO (#o0003) via COPROCESSOR-WRITE (#o157).
    2. Writing R1_HI to an operation trigger port (opcode + 1) executes the IEEE-754 single/double operation (add, sub, mul, div, sqrt, neg, abs, compare, fix/float conversions) under the active SR0 rounding mode, latches SR3/SR6/SR11, and sets last_fpex if any unmasked SR2 exception fires.
    3. Software reads results from #o0002 (RES_HI: tagged DTP_SINGLE_FLOAT if !last_fpex, else DTP_FIXNUM signaling software trap recovery), #o0003 (RES_LO), or #o0400; for comparisons, reading opcode + 2 returns T, NIL, or DTP_FIXNUM 0 on last_fpex.

6. Hardware Traps & Rev 4 / Rev 4A Error Microstates

Trap dispatch routes through vector_base + trap_offset, where vector_base is 0xF8040000 in modes 0..2 and %REGISTER-FEP-MODE-TRAP-VECTOR-ADDRESS (#o1024) in mode 3 (FEP):

Vector Range (Octal)ClassMeaning
#o0000..#o3777Post-TrapArithmetic exception dispatch (op, dtp1, dtp2)
#o4000..#o4377Post-TrapUnimplemented / software-emulated opcode (#o4000 + op)
#o4400..#o4477Post-TrapInterpreter / non-compiled function call (#o4400 + dtp)
#o5000Post-TrapGeneric dispatch table
#o5100..#o5127Pre/PostHardware traps: ERROR (#o5100), RESET (#o5101), STACK_OVERFLOW (#o5103), PREEMPT (#o5105), TRANSPORT (#o5106), FEP_MODE (#o5107), LOW/HIGH_PRIO_SEQ_BREAK (#o5110..#o5111), MONITOR (#o5112), PAGE_NOT_RESIDENT (#o5120), PAGE_FAULT_REQUEST (#o5121), PAGE_WRITE_FAULT (#o5122), MEMORY_BUS_ERROR (#o5124), DB_UNWIND_FRAME/CATCH (#o5126..#o5127)

When IVORY_TRAP_ERROR (#o5100) fires, the trap frame passes an Ivory Rev 4 / Rev 4A microstate code (0x0000..0x07FF, identical across Rev 4 and Rev 4A) that indexes Genera 8.3's 2,048-entry *TRAP-DISPATCH-TABLE* (e.g., 0x0000 ILLEGAL_FULLWORD_INSTR, 0x0034 TOO_FEW_ARGUMENTS, 0x0047 MEMORY_DATA_ERROR -> CLOS:SLOT-UNBOUND with vma_valid=1, 0x0057 BAD_CDR_CODE_IN_MEMORY, 0x008F SUBSCRIPT_BOUNDS_ERROR, 0x011E I_STAGE_ERROR, 0x04C9 TRAP_ON_EXIT, 0x0559 DIVIDE_BY_ZERO, 0x0613 TOO_MANY_ARGUMENTS, plus Wrong-Type-Argument microstates 0x0408..0x07E4).

For the full trap vector listing, microstate table, and *BOOT-SPY-PC* halt vector, see Traps, Interrupts & Exception Handling.

Related Chip Datasheets (3)All Component Datasheets →