Micro Programming 2
Micro Program 2
The following is the the Micro Program of Tanenbaum's Machine (as
the Macro Instruction Fetch and a Macro Instruction Interpreter):
| Line | MAL Instruction | Comment |
| 0 | mar:=pc; rd; | MAR<-PC, Read MEM |
| 1 | pc:=pc+1; rd; | PC<-PC+1, Read MEM |
| 2 | ir:=mbr; if N then goto 28; | if MacroOPcode in IR starts with "1XXX..." jump to Line28 |
| 3 | tir:=lshift(ir+ir); if N then goto 19; | copy Bit13.. of IR to TIR; if OPcode is 01XX jump to 19 |
| 4 | tir:=lshift(tir); if N then goto 11; | copy Bit12.. of TIR to TIR; if OPcode is 001X jump to 11 |
| 5 | alu:=tir; if N then goto 9; | send TIR to ALU; if OPcode is 0001 jump to 9 |
| 6 | mar:=ir; rd; | start executing Macro Instruction "0000..." (LODD) |
| 7 | rd; | Read MEM |
| 8 | ac:=mbr; goto 0; | store the contents of MEM pointed by MAR to AC; |
| back to Line 0 | ||
| 9 | mar:=ir; mbr:=ac; wr; | start executing Macro Instruction "0001..."(STOD) |
| 10 | wr; goto 0; | copy AC to MEM pointed by MAR; |
| back to Line 0 | ||
| 11 | alu:=tir; if N then goto 15; | if (Level 1)OPcode is 0011 jump to Line 15 |
| 12 | mar:=ir; rd; | start executing Macro Instruction "0010..."(ADDD) |
| 13 | rd; | read MEM |
| 14 | ac:=mbr+ac; goto 0; | add AC and the contents of MEM pointed by MAR, store it to AC |
| back to Line 0 | ||
| 15 | mar:=ir; rd; | start executing Macro Instruction "0011..."(SUBD) |
| 16 | ac:=ac+1; rd; | prepare for computing X-Y=(X+1)+not(Y) |
| 17 | a:=inv(mbr); | copy not(MBR) to A register |
| 18 | ac:=ac+a; goto 0; | finish AC=AC-m[...] |
| back to Line 0 | ||
| 19 | tir:=lshift(tir); if N then goto 25; | copy Bit12.. of IR to TIR; if OPcode is 011X jump to 25 |
| 20 | alu:=tir; if N then goto 23; | if OPcode is 0101 jump to 23 |
| 21 | alu:=ac; if N then goto 0; | start executing Macro Instruction "0100..."(JPOS) |
| if AC is negative, go back to Line 0 | ||
| 22 | pc:=band(ir,amask); goto 0; | copy lower 12 bit of IR to PC, go back to Line 0 |
| 23 | alu:=ac; if Z then goto 22; | start executing Macro Instruction "0101..."(JZER) |
| if AC is zero, go to Line 22 | ||
| 24 | goto 0; | back to 0 |
| 25 | alu:=tir; if N then goto 27; | if OPcode is 0111 jump to 27 |
| 26 | pc:=band(ir,amask); goto 0; | start executing Macro Instruction "0110..."(JUMP) |
| copy lower 12 bit of IR to PC, go back to Line 0 | ||
| 27 | ac:=band(ir,amask); goto 0; | start executing Macro Instruction "0111..."(LOCO) |
| copy lower 12 bit of IR to AC, go back to Line 0 | ||
| 28 | tir:=lshift(ir+ir); if N then goto 40; | copy Bit13.. of IR to TIR; if OPcode is 11XX jump to 40 |
| 29 | tir:=lshift(tir); if N then goto 35; | copy Bit12.. of TIR to TIR; if OPcode is 101X jump to 35 |
| 30 | alu:=tir; if N then goto 33; | if OPcode is 1001, jump to 33 |
| 31 | a:=ir+sp; | start executing Macro Instruction "1000..."(LODL) |
| 32 | mar:=a; rd; goto 7; | move SP+(lower 12 bit of IR) to MAR
(store the contents of MEM pointed by MAR to AC back to Line 0) |
| 33 | a:=ir+sp; | start executing Macro Instruction "1001..."(STOL) |
| 34 | mar:=a; mbr:=ac; wr; goto 10; | copy SP+(lower 12 bit of IR) to MAR, copy AC to MBR
(write AC to MEM pointed by MAR back to Line 0) |
| 35 | alu:=tir; if N goto 38; | if OPcode is 1011, jump to 38 |
| 36 | a:=ir+sp; | start executing Macro Instruction "1010..."(ADDL) |
| 37 | mar:=a; rd; goto 13 | copy SP+(lower 12 bit of IR) to MAR, Read MEM,
(add AC and the contents of MEM pointed by MAR, store it to AC, back to Line 0) |
| 38 | a:=ir+sp; | start executing Macro Instruction "1011..."(SUBL) |
| 39 | mar:=a; rd; goto 16 | copy SP+(lower 12 bit of IR) to MAR, Read MEM,
( AC=AC-m[MAR], back to Line 0 ) |
| 40 | tir:=lshift(tir); if N then goto 46; | copy Bit12.. of IR to TIR; if OPcode is 111X jump to 46 |
| 41 | alu:=tir; if N then goto 44; | if OPcode is 1101 jump to 44 |
| 42 | alu:=ac; if N then goto 22; | start executing Macro Instruction "1100..."(JNEG) |
| (if N, jump to the location given by lower 12 bit of IR back to Line 0) | ||
| 43 | goto 0; | otherwise(:not N), back to Line 0 |
| 44 | alu:=ac; if Z then goto 0 | start executing Macro Instruction "1101..."(JNZE)
if Z, then back to Line 0 |
| 45 | pc:=band(ir,amask); goto 0; | (if NZ, jump to the location given by lower 12 bit of IR back to Line 0) |
| 46 | tir:=lshift(tir); if N goto 50; | if OPcode starts with "1111...", jump to 50 |
| 47 | sp:=sp+(-1); | start executing Macro Instruction "1110..."(CALL) |
| 48 | mar:=sp; mbr:=pc; wr; | store PC to the stack |
| 49 | pc:=band(ir,amask); wr; goto 0; | store PC with the location given by lower 12 bit of IR |
| back to Line 0 | ||
| 50 | tir:=lshift(tir); if N goto 65; | if OPcode starts with "11111..." jump to 65 |
| 51 | tir:=lshift(tir); if N goto 59; | if OPcode starts with "111101..." jump to 59 |
| 52 | alu:=tir; if N goto 56; | if OPcode starts with "1111001..." jump to 56 |
| 53 | mar:=ac; rd; | start executing Macro Instruction "1111000..."(PSHI) |
| 54 | sp:=sp+(-1); rd; | copy m[AC] to MBR, allocate SP |
| 55 | mar:=sp; wr; goto 10 | push m[AC] on the stack |
| (back to Line 0) | ||
| 56 | mar:=sp; sp:=sp+1; rd; | start executing Macro Instruction "1111001..."(POPI) |
| 57 | rd; | copy SP to MAR, increment SP |
| 58 | mar:=ac; wr; goto 10; | move the top of the stack to m[AC] |
| (back to Line 0) | ||
| 59 | alu:=tir; if N then goto 62; | if OPcode starts with "1111011..." jump to 62 |
| 60 | sp:=sp+(-1); | start executing Macro Instruction "1111010..."(PUSH) |
| 61 | mar:=sp; mbr:=ac; wr; goto 10 | push AC on the stack |
| back to Line 0 | ||
| 62 | mar:=sp; sp:=sp+1; rd; goto 10 | start executing Macro Instruction "1111011..."(POP) |
| 63 | rd; | |
| 64 | ac:=mbr; goto 0; | pop the top of the stack to AC |
| back to Line 0 | ||
| 65 | tir:=lshift(tir); if N goto 73; | if OPcode starts with "111111..." jump to 73 |
| 66 | alu:=tir; if N goto 70; | if OPcode starts with "1111101..." jump to 70 |
| 67 | mar:=sp; sp:=sp+1; rd; | start executing Macro Instruction "1111100..."(RETN) |
| 68 | rd; | |
| 69 | pc:=mbr; goto 0; | move the return address from the stack to PC |
| back to Line 0 | ||
| 70 | a:=ac; | start executing Macro Instruction "1111101..."(SWAP) |
| 71 | ac:=sp; | |
| 72 | sp:=a; goto 0; | swap AC and SP (A<-AC, AC<-SP, SP<-A) |
| back to Line 0 | ||
| 73 | alu:=tir; if N then goto 76; | if OPcode starts with "1111111..." jump to 76 |
| 74 | a:=band(ir,smask); | start executing Macro Instruction "1111110..."(INSP) |
| 75 | sp:=sp+a; goto 0; | increment SP by the lower 12 bit of IR |
| back to Line 0 | ||
| 76 | a:=band(ir,smask); | start executing Macro Instruction "1111111..."(DESP) |
| 77 | a:=inv(a); | prepare -A |
| 78 | a:=a+1; goto 75; | (decrement SP by the lower 12 bit of IR |
| back to Line 0) |