{eris}work>DT>DOpcodeRec.tedit Sun 30 Mar 86 M Herring This is to document the format of a D-machine OPCODE record, as in \OPCODES or an atom's DOPCODE property. Especially: all the odd forms the OPPRINT and LEVADJ fields can take. Some duplication of Herb's ImplManual chapter. Includes lists of opcodes that have a particular oddity and the exact format of the argument bytes of opcodes with odd formats. These latter lists are for the D-machine, as of 11 Oct 85, more or less, and of course should not be believed too hard. Also document: the new Tamarin OPPRINTs & LEVADJs. I've also started to put in "D-machine only" & similar comments; not to be relied on much at all at this point. Otherwise, so far the Tamarin OPCODE record format is the same as that for the D-machine, with the understanding that multi-byte in-line arguments in Tamarin code are presented least significant byte first, whereas in D-machine code they are presented most significant byte first. Also not that Tamarin is starting to have OPPRINTs that look back at their OPNARGSs to see exactly what their format is (vs. e.g. JUMP JUMPX JUMPXX would have been one OPPRINT if done in this way). This, or at least its OPPRINT & Tamarin information, should be added to {eris}internal>doc>ImplManual.tedit after appropriate editing. Contents-- The players OPCODE record for D-machine OPPRINT field of D-machine OPCODE record new, Tamarin-only OPPRINTs meanings of argument bytes when OPPRINT=T / NIL -- when not just one simple number per byte LEVADJ field of D-machine OPCODE record new, Tamarin-only LEVADJs Some questions The players-- \OPCODES -- list of the DOPCODE records in the system. Set \OPCODEARRAY NIL if you change this. \OPCODEARRAY -- array-ized version of \OPCODES, else NIL in which case \FINDOP will rebuild \OPCODEARRAY from \OPCODES . DOPCODE property of an opcode atom (\FINDOP opcode-name-or-number) => OPCODE record. PRINTCODE -- renamed from DPRINTCODE in file ACODE -- knows how to print a CCODEP; uses OPCODE records to do this. On Koto, 23 Oct 85, uses OPCODENAME OPNARGS OPPRINT LEVADJ fields. CALLSCCODE -- renamed from DCALLSCCODE in file ACODE. On Koto, 23 Oct 85, uses OPCODENAME OPNARGS OPPRINT fields. CHANGECCODE -- renamed from DCHANGECCODE in file ACODE. On Koto, 23 Oct 85, uses OPCODENAME OPNARGS OPPRINT fields. PRINTOPCODES -- in file ACODE. On Koto, 23 Oct 85, uses OPCODENAME OPNARGS OPPRINT LEVADJ fields. TPC, DPC, PC in {eris}current>DT>, files TASM, DASM, PC. New version of PRINTCODE. Still developing. Knows about Tamarins. Doesn't cooperate with Teleraid at this writing. OPCODE record for D-machine-- OP# numeric value of opcode byte -OR- (first last) range of such numbers for those opcodes that contain an implicit constant, namely IVAR PVAR FVAR , IVAR_ PVAR_ FVAR_ , PVAR_^ , JUMP FJUMP TJUMP OPCODENAME atom OPNARGS number of alpha/beta/gamma argument-bytes that follow the opcode byte in the compiled code. Can affect the meaning of this OPCODE's OPPRINT . OPPRINT special token. How to print the instruction. See table below. Used only by PRINTCODE ? LEVADJ stack effect: +/-n or special token. See table below. Used only by PRINTCODE ? UFNFN name of the UFN, or NIL if none. Actually read by MAKEINIT . UNIMPL which machines do not implement this opcode in microcode. (DOLPHIN not listed anymore.) One of: NIL -- default -- implemented everywhere T -- not implemented in anyone's microcode one or a list of: DORADO, 4K, 12K * -- used for PLUS2 DIFFERENCE TIMES2 QUOTIENT -- [means what??] OPPRINT field of D-machine OPCODE record-- herein: k is the number implicit in the opcode (for those opcodes that have a numeric range for OP#). Alpha [beta, gamma] are the first [2nd, 3rd] argument bytes following the opcode (when present according to OPNARGS). ",," is the concatenation operator. ".." means "through". OPPRINT OPNARGS format of the argument bytes T / NIL n opcode byte is followed by n alpha/beta bytes / default PRINTCODE treats them as separate octal numbers. A following section lists those opcodes which have OPPRINT= T / NIL but whose argument bytes are not just simply separate numbers. (atom ..) 1 alpha is subopcode: PRINTCODE uses alpha as an index into this list (0 -> first) for opcode name. [If LEVADJ is also a list, this subopcode indexes into it as well ??] SIC 1 alpha is a small positive integer -- used for SIC only SNIC 1 alpha represents a small negative integer formed by appending one-bits to the left of alpha -- SNIC only SICX 2 alpha,,beta is a small positive integer -- SICX only GCONST 3 D-machine only -- alpha,,0,,beta,,gamma is a 32-bit immediate quantity [??] -- used for GCONST only TYPEP 1 alpha is a type, that is a type-table byte -- used for TYPEP only, but that's used in lots of DOPVALs. PRINTCODE knows about several of these argument bytes by name: ARRAYP FIXP FLOATP LITATOM SMALLP STACKP STRINGP ATOM 2 alpha,,beta is the index of an atom. Used by ACONST ATOMNUMBER DTEST GVAR GVAR_ FN 2 k is the number of arguments that the function finds on the stack; alpha,,beta is the atom-index of the function -- FN0 .. FN4 only FNX 3 D-machine only -- alpha is the number of arguments that the function finds on the stack; beta,,gamma is the atom-index of the function -- FNX only SUBRCALL 2 D-machine only -- alpha is a "subroutine number", i.e. the 1-based number of the subroutine in list \INITSUBRS [??]; beta is the number of arguments that the subroutine finds on the stack -- SUBRCALL only IVAR 0..1 D-machine only-- if OPNARGS is 0, k is the Basic-frame slot-number; if OPNARGS is 1, alpha is twice that, i.e. the word offset of the slot relative to the beginning of the frame -- IVAR IVARX IVARX_ only. In lambda* functions, these opcodes can be accesses to the arguments, in which case the number encoded is the 0-based argument number. FVAR 0..1 D-machine -- if OPNARGS is 0, k is the FX-frame slot-number; if OPNARGS is 1, alpha is twice that, i.e. the word offset of the slot relative to the beginning of the pvar/fvar region of the frame -- FVAR FVARX FVARX_ only. Tamarin -- if OPNARGS is 0, k is the slot-number in the stack frame; if OPNARGS is 1, alpha isthe slot-number in the stack frame. PVAR 0..1 D-machine -- if OPNARGS is 0, k is the FX-frame slot-number; if OPNARGS is 1, alpha is twice that, i.e. the word offset of the slot relative to the beginning of the pvar/fvar region of the frame -- PVAR PVARX PVARX_ PVARX_ PVAR_^ only. Tamarin -- if OPNARGS is 0, k is the slot-number in the stack frame; if OPNARGS is 1, alpha isthe slot-number in the stack frame. JUMP 0 k is (number of bytes to jump (forward) from zeroth byte of the jump instruction) - 2 -- used for JUMP FJUMP TJUMP JUMPX 1 alpha is (signed) number of bytes to jump from zeroth byte of the jump instruction -- used for JUMPX FJUMPX TJUMPX , NFJUMPX NTJUMPX JUMPXX 2 alpha,,beta is (signed) number of bytes to jump from zeroth byte of the jump instruction -- used for JUMPXX only new, Tamarin-only OPPRINTs-- ATOM 2/3 as D-machine ATOM except uses 3-byte atom-numbers if OPNARGS=3. ICONST 4 delta,,gamma,,beta,,alpha is a 32-bit number. The major type bits are forced to "Tamarin FIXP". PCONST 4 delta,,gamma,,beta,,alpha is a 32-bit pointer. (If delta is 0 then it is a "backwards-compatible" (D-machine) pointer.) The major type bits are forced to "Tamarin pointer". Meanings of argument bytes when OPPRINT=T / NIL -- when not just one simple number per byte BIND -- alpha high 4 bits is # of pvars to be bound NIL; alpha low 4 bits is # of pvars to be bound to values taken off the computation stack; these pvars' slots are all contiguous; beta is the highest-numbered of them; the bind-NIL slots are higher numbered; the highest-numbered bind-from-stack slot gets the topmost value on the stack. GCREF - alpha is: 0 addref; 1 delref; 2 stackref TYPEMASK.N -- alpha is a bit mask on the type-table type byte?? ATOMCELL.N -- alpha is some kind of superpage number: 2x the atom index is appended to its right. GETBITS.N.FD & PUTBITS.N.FD -- alpha is offset in words; beta high 4 bits is leftmost bit number (counting L->R 0->15); beta low 4 bits is number of bits -1. LEVADJ field of D-machine OPCODE record-- n or -n -- stack effect (numeric-stack-effect 1) -- return is unboxed floating point. Used for UBFLOAT1 UBFLOAT2 UBFLOAT3. [At this writing, 57-DOVEMISC has a list of numeric stack effects, which is intended to correspond to the list of subopcode names which is its OPPRINT. This is wrong.] JUMP -- renders the stack level unknown as of the following instruction, but the old stack level is attributed to the jump target address. Used for JUMP JUMPX JUMPXX CJUMP -- stack effect is -1, but the new stack level is also attributed to the jump target address. Used for FJUMP TJUMP , FJUMPX TJUMPX NCJUMP -- stack effect is -1, but the old stack level is attributed to the jump target address. Used for NFJUMPX NTJUMPX (JUMP 1) -- renders the stack level unknown as of the following instruction. Used for RETURN (POP.N 1) -- stack effect is -(#args, =alpha) -- POP.N only FNX -- stack effect is +1-(#args, =alpha) -- FNX only SUBRCALL -- stack effect is +1-(#args, =beta) -- SUBRCALL only NIL -- default -- used for BIND -- stack effect is +1-(#vars bound from values on the stack, =low 4 bits of alpha). There is also the binding-stack effect: of binding (high 4 bits of alpha)+(low 4 bits of alpha) pvars, which have contiguous binding-slots, the highest-numbered slot being that numbered beta. UNBIND -- stack effect is to restore to the level as after the corresponding BIND (-1 for the binding marker, +1 for the returned value). There is also the binding-stack effect: of unbinding those pvars the corresponding BIND bound. The "corresponding" BIND is really: the first binding marker found by scanning from the top of the stack towards the bottom. DUNBIND -- stack effect is to restore to the level as after the corresponding BIND (-1 for the binding marker). There is also the binding-stack effect: of unbinding those pvars the corresponding BIND bound. The "corresponding" BIND is really: the first binding marker found by scanning from the top of the stack towards the bottom. -X- new, Tamarin-only LEVADJs-- TUNBIND -- stack pointer is set to alpha Some questions-- UNIMPL field -- DOLPHIN not listed anymore? UNIMPL field -- * means what? 248 FLOATBLT has OPNARGS 0 & OPPRINT a list & OP# a number !! DOVEMISC has a list of LEVADJs -- this is illegal, but ok as long as it never ufns.1´`x4œT„ä(H1´Tr($MODERN €MODERN €MODERN MODERN  ܇v  *^)ay#2·suc¹!¥˜bXCM+-&C$ ^f#8 ¥2d * =Ô FC 6C /_T,3ý(0‹:')0š:'Q€  fI H v - ' M)›'-P 7$§Šz^'#(RG\lQ#,>S)¬¡zº