// SwatInsAnal.bcpl - Routines for analyzing Alto instructions // Copyright Xerox Corporation 1979, 1981, 1982 // Last modified March 21, 1982 2:10 PM by Boggs // All you have to do is...07/25/73 (alb) get "Swat.decl" external [ // outgoing procedures SymbolicInst; EffAddr; BuildSI // incoming procedures VMFetch; ReportFail; AddrToSym Ws; PutTemplate; Puts; Zero // incoming statics dsp; xmFlag ] structure OP: // instruction fields [ [ alu bit 1 acSrc bit 2 acDest bit 2 aluFn bit 3 shift bit 2 carry bit 2 noLoad bit 1 skip bit 3 ] = [ f1 bit 3 f2 bit 2 = ac bit 2 indir bit 1 index bit 2 disp bit 8 ] ] structure SI: // Simulated Instruction [ instr word // simulating instruction doItRtn word // 0: default, 1: jmp, 2: bri simRtn word // simulation routine dispatch (small integer) disp word // sign extended displacement eaReg word // 0, or -> trapAdd, trapAC2, or AC3 indir word // number of times to indirect (0-2) ] compileif size SI/16 ne 6 then [ Error("Change lenSI declaration in Swat.decl") ] manifest [ // SI.sim values -- *** known to SwatResident.asm *** simMRIALU = 0 // Memory Reference and Arithmetic Logical instrs simJmp = 1 simJsr = 2 simDirs = 3 simBRI = 4 // SI.doIt values -- *** known to SwatResident.asm *** doItDefault = 0 doItJmp = 1 doItBRI = 2 ] //---------------------------------------------------------------------------- let EffAddr(instr, addr, returnIfNoEA; numargs na) = valof //---------------------------------------------------------------------------- [ let disp = Displacement(instr) test (instr & 177400B) eq 64400B //JSRII ifso resultis VMFetch(VMFetch(disp+addr)) ifnot test (instr & 177400B) eq 65000B //JSRIS ifso resultis VMFetch(VMFetch(disp+VMFetch(userAC2))) ifnot [ if instr<>SI.instr = 401b //jmp .+1 si>>SI.doItRtn = doItDefault si>>SI.disp = Displacement(instr) si>>SI.eaReg = selecton instr<>SI.simRtn = simJmp endcase ] case 1: // jsr [ si>>SI.simRtn = simJsr endcase ] case 2: // isz case 3: // dsz [ si>>SI.simRtn = simMRIALU si>>SI.instr = (instr & 74000b) + 2405b //op @.+5 endcase ] ] si>>SI.indir = instr<>SI.simRtn = simMRIALU si>>SI.instr = (instr & 74000b) + 2405b //op @.+5 si>>SI.indir = instr<>SI.simRtn = simMRIALU si>>SI.instr = instr endcase ] // BuildSI (cont'd) case 3: // special Alto instructions [ let i = instr & 77400b test i eq 64400b % i eq 65000b // jsrii, jsris ifso [ si>>SI.simRtn = simJsr si>>SI.indir = 2 ] ifnot switchon instr into [ case 61000b: // dir [ si>>SI.doItRtn = doItJmp endcase ] case 61001b: // eir [ si>>SI.doItRtn = doItBRI endcase ] case 61002b: // bri [ si>>SI.simRtn = simBRI si>>SI.doItRtn = doItBRI endcase ] case 61013b: // dirs [ si>>SI.simRtn = simDirs si>>SI.doItRtn = doItJmp endcase ] default: // simMRIALU works for the rest of them [ si>>SI.simRtn = simMRIALU // don't re-execute traps unless i eq 77400b do si>>SI.instr = instr if xmFlag & ((instr & xJmpInstMask) eq xJmp0) then ReportFail("I Can't simulate xJmp instructions") endcase ] ] endcase ] ] ] //---------------------------------------------------------------------------- and SymbolicInst(instr, addr) be //---------------------------------------------------------------------------- // Print instr as an Alto instruction assuming it resides at addr. [ PutTemplate(dsp, "$6UO ", instr) test instr< $P: $UO", AddrToSym, effAdd, VMFetch(effAdd)) ] //---------------------------------------------------------------------------- and Displacement(instr) = (instr<