Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- instruction encoding
- control word encoding:
- ---------------------------------------------------------------------------------------------------------------------------------
- | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 |
- |-------------------------------------------------------------------------------------------------------------------------------|
- | Registers |
- |-------------------------------------------------------------------------------------------------------------------------------|
- | $x | $y | PC | CIR | MAR | MDR | Run | Opc | BP | SP |
- |-------------------------------------------------------------------------------------------------------------------------------|
- | I | O | I | O | I | O | I | I | I | O | I | O | I | O | I | O |
- ---------------------------------------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------------------------------------
- | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
- |-------------------------------------------------------------------------------------------------------------------------------|
- | ALU inputs | ALU outputs | | |
- |---------------------------------------------------------------------------------------------------------------| | |
- | 1 | 2 | add | sub | inc | dec | not | and | or | xor | slt | srl | mult | div | mall | end |
- |---------------------------------------------------------------------------------------------------------------| | |
- | I | I | O | O | O | O | O | O | O | O | O | O | O | O | | |
- ---------------------------------------------------------------------------------------------------------------------------------
- bank[x] is shorthand for mem[$$bp * 16 + x]
- add $x, $y
- encoding: 000000XY
- description: $x += $y
- microcode:
- xo alu1
- yo alu2
- add xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000010000000000001
- sub $x, $y
- encoding: 000001XY
- description: $x -= $y
- microcode:
- xo alu1
- yo alu2
- sub xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000001000000000001
- halt
- encoding: 00001000
- description: Stop execution
- microcode:
- runi end
- 00000000001000000000000000000001
- rst
- encoding: 00001001
- description: Set all the registers to 0, clear memory after program
- microcode:
- xi yi pci bpi spi alu1 alu2 mdri mari end
- 10101001100010101100000000000001
- brk $x
- encoding: 0000101X
- description: Write $x to the continuously-displayed 1-byte breakpoint buffer
- (and then start stepping through execution?)
- inc $x
- encoding: 0000110X
- description: $x ++
- microcode:
- xo alu1
- inc xi end
- 01000000000000001000000000000000
- 10000000000000000000100000000001
- dec $x
- encoding: 0000111X
- description: $x --
- microcode:
- xo alu1
- dec xi end
- 01000000000000001000000000000000
- 10000000000000000000010000000001
- not $x, $y
- encoding: 000100XY
- description: $x = ~$y
- microcode:
- xo alu1
- yo alu2
- not xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000001000000001
- and $x, $y
- encoding: 000101XY
- description: $x &= $y
- microcode:
- xo alu1
- yo alu2
- and xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000100000001
- or $x, $y
- encoding: 000110XY
- description: $x |= $y
- microcode:
- xo alu1
- yo alu2
- or xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000010000001
- xor $x, $y
- encoding: 000111XY
- description: $x ^= $y
- microcode:
- xo alu1
- yo alu2
- xor xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000001000001
- li $x, imm
- encoding: 001XIIII
- description: $x = imm
- microcode:
- opco xi end
- 10000000000100000000000000000001
- slt $x, $y
- encoding: 010000XY
- description: $x = ($x < $y)
- microcode:
- xo alu1
- yo alu2
- slt xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000000100001
- srl $x, $y
- encoding: 010001XY
- description: $x >>= $y ($y signed)
- microcode:
- xo alu1
- yo alu2
- srl xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000000010001
- mult $x, $y
- encoding: 010010XY
- description: $x *= $y
- microcode:
- xo alu1
- yo alu2
- mult xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000000001001
- div $x, $y
- encoding: 010011XY
- description: $x /= $y
- microcode:
- xo alu1
- yo alu2
- div xi end
- 01000000000000001000000000000000
- 00010000000000000100000000000000
- 10000000000000000000000000000101
- j imm
- encoding: 0101IIII
- description: $$pc = imm
- microcode:
- bpo opco pci end
- 00001000000101000000000000000001
- jnez $x, imm
- encoding: 011XIIII
- description: if ($x) $$pc = imm
- microcode:
- bpo opco pci end
- 00001000000101000000000000000001
- lw $x, [imm]
- encoding: 100XIIII
- description: $x = bank[imm]
- microcode:
- bpo opco mari
- mdro xi end
- 00000001000101000000000000000000
- 10000000010000000000000000000001
- sw $x, [imm]
- encoding: 101XIIII
- description: bank[imm] = $x
- microcode:
- bpo opco mari
- xo mdri end
- 00000001000101000000000000000000
- 01000000100000000000000000000001
- lw $x, [$y]
- encoding: 110000XY
- description: $x = mem[$y]
- microcode:
- yo mari
- mdro xi end
- 00010001000000000000000000000000
- 10000000010000000000000000000001
- sw $x, [$y]
- encoding: 110001XY
- description: mem[$y] = $x
- microcode:
- yo mari
- xo mdri end
- 00010001000000000000000000000000
- 01000000100000000000000000000001
- copy [$x], [$y]
- encoding: 110010XY
- description: mem[$x] = mem[$y]
- microcode:
- yo mari
- mdro alu1 alu2
- xo mari
- mdri and end
- 00010001000000000000000000000000
- 00000000010000001100000000000000
- 01000001000000000000000000000000
- 00000000100000000000000100000001
- swap [$x], [$y]
- encoding: 110011XY
- description: tmp = mem[$x]; mem[$x] = mem[$y]; mem[$y] = tmp
- microcode:
- xo mari
- mdro alu1
- yo mari
- mdro alu2
- xor alu1
- xor mdri alu2
- xo mari
- xor mdri end
- 01000001000000000000000000000000
- 00000000010000001000000000000000
- 00010001000000000000000000000000
- 00000000010000000100000000000000
- 00000000000000001000000001000000
- 00000000100000000100000001000000
- 01000001000000000000000000000000
- 00000000100000000000000001000001
- push $x
- encoding: 1101000X
- description: mem[$$sp] = $x; $$sp ++
- microcode:
- spo alu1
- inc spi mari
- mdri xo end
- 00000000000000011000000000000000
- 00000001000000100000100000000000
- 01000000100000000000000000000001
- pop $x
- encoding: 1101001X
- description: $x = mem[$$sp]; $$sp --
- microcode:
- spo mari alu1
- xi mdro
- dec spi end
- 00000001000000011000000000000000
- 10000000010000000000000000000000
- 00000000000000100000010000000001
- call $x
- encoding: 1101010X
- description: mem[$$sp] = $$pc; $$sp ++; $$pc = $x
- microcode:
- spo alu1
- inc spi mari
- pco mdri
- xo pci end
- 00000000000000011000000000000000
- 00000001000000100000100000000000
- 00000100100000000000000000000000
- 01001000000000000000000000000001
- init
- encoding: 11010110
- description: $$sp = &bank[0] OR $$sp = $$bp * 16
- microcode:
- bpo spi end
- 00000000000001100000000000000001
- rts
- encoding: 11010111
- description: $$pc = mem[$$sp]; $$sp --;
- microcode:
- spo mari alu1
- dec spi
- mdro pci end
- 00000001000000011000000000000000
- 00000000000000100000010000000000
- 00001000010000000000000000000001
- ???
- encoding: 110110XY
- description:
- ???
- encoding: 110111XY
- description:
- bnk $x
- encoding: 1110000X
- description: $$bp = $x
- microcode:
- xo bpi end
- 01000000000010000000000000000001
- incb
- encoding: 11100010
- description: $$bp ++
- microcode:
- bpo alu1
- inc bpi end
- 00000000000001001000000000000000
- 00000000000010000000100000000001
- decb
- encoding: 11100011
- description: $$bp --
- microcode:
- bpo alu1
- dec bpi end
- 00000000000001001000000000000000
- 00000000000010000000010000000001
- addb $x
- encoding: 1110010X
- description: $$bp += $x
- microcode:
- bpo alu1
- xo alu2
- add bpi end
- 00000000000001001000000000000000
- 01000000000000000100000000000000
- 00000000000010000010000000000001
- subb $x
- encoding: 1110011X
- description: $$bp -= $x
- microcode:
- bpo alu1
- xo alu2
- sub bpi end
- 00000000000001001000000000000000
- 01000000000000000100000000000000
- 00000000000010000001000000000001
- ???
- encoding: 111010XY
- description:
- ???
- encoding: 111011XY
- description:
- bnki imm
- encoding: 1111IIII
- description: $$bp = imm
- microcode:
- opco bpi end
- 00000000000110000000000000000001
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement