thomasfn

Instruction Set

Apr 25th, 2013
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. 32-bit instruction set for the SHA-PU
  2.  
  3. == Registers ==
  4. PC = Program Counter (not addressable)
  5. GP0 - GP7 = General Purpose
  6.  
  7. == Instruction Breakdown ==
  8. <opcode : 8 bits> <dst register : 4 bits> <srcA register : 4 bits> <srcB register : 4 bits> <padding : 12 bits>
  9.  
  10. GP0 - GP7 = 0000 - 0111
  11.  
  12. == Instructions ==
  13. == Data Transfer and Jumping ==
  14. MOVE <dst> <src> = Move a value from <src> reg to <dst> ref
  15. MOVE <dst> <value> = Move a value into <dst> reg, <value> is the final 16 bits within the instruction
  16. LOAD <dst> <addr> = Load a value from ram at <addr> into <dst> reg, <addr> is the final 16 bits within the instruction
  17. LOAD <dst> <src> = Load a value from ram at the address in <src> reg
  18. STORE <srcA> <addr> = Store the value in <srcA> reg in ram at <addr>, <addr> is the final 16 bits within the instruction
  19. STORE <dst> <src> = Store the value in <dst> reg in ram at the address in <src> reg
  20. JMP <addr> = Sets the PC to <addr>, <addr> is the final 16 bits within the instruction
  21. JMP <srcA> = Sets the PC to the value in <srcA> reg
  22. JMPC <src> <addr> = Sets the PC to <addr> if the value in <src> is > 0, <addr> is the final 16 bits within the instruction
  23. JMPC <srcA> <srcB> = Sets the PC to the value in <srcB> if the value in <src> is > 0, <addr> is the final 16 bits within the instruction
  24. NOOP = Does nothing
  25.  
  26. == Arithmetic and Logic ==
  27. ADD <dst> <srcA> <srcB> = Adds <srcA> to <srcB> and stores in <dst>
  28. SUB <dst> <srcA> <srcB> = Subtracts <srcB> from <srcA> and stores in <dst>
  29. MUL <dst> <srcA> <srcB> = Multiplies <srcA> with <srcB> and stores in <dst>
  30.  
  31. AND <dst> <srcA> <srcB> = Performs logical AND with <srcA> and <srcB> and stores in <dst>
  32. OR <dst> <srcA> <srcB> = Performs logical OR with <srcA> and <srcB> and stores in <dst>
  33. XOR <dst> <srcA> <srcB> = Performs logical XOR with <srcA> and <srcB> and stores in <dst>
  34. NOT <dst> <srcA> = Performs logical NOT with <srcA> and stores in <dst>
  35.  
  36. RSHIFT <dst> <srcA> <srcB> =
  37.  
  38. == Comparisons ==
  39. EQL <dst> <srcA> <srcB> = If <srcA> == <srcB>, fills <dst> with 1 - else fills with 0
  40. LESS <dst> <srcA> <srcB> = If <srcA> < <srcB>, fills <dst> with 1 - else fills with 0
  41. MORE <dst> <srcA> <srcB> = If <srcA> > <srcB>, fills <dst> with 1 - else fills with 0
  42. LEQL <dst> <srcA> <srcB> = If <srcA> <= <srcB>, fills <dst> with 1 - else fills with 0
  43. MEQL <dst> <srcA> <srcB> = If <srcA> >= <srcB>, fills <dst> with 1 - else fills with 0
  44. NEQL <dst> <srcA> <srcB> = If <srcA> != <srcB>, fills <dst> with 1 - else fills with 0
  45.  
  46. == Opcode Breakdown ==
  47.  
  48. 8 bits
  49. [usealu : 1 bit]
  50. if usealu is 1:
  51. [alutype : 6 bit]
  52. sourcedata = 110/6
  53. destdata = 00/0
  54. if usealu is 0:
  55. [sourcedata : 3 bit] [destdata : 2 bit] [padding : 1 bit]
  56. alutype = 0
  57. [conditional : 1 bit]
  58.  
  59. alutype = what operation for the ALU to perform
  60. 00 0000/0x00 = add
  61. 00 0001/0x01 = sub
  62. 00 0010/0x02 = mul
  63.  
  64. 00 1000/0x08 = rshift
  65. 00 1001/0x09 = lshift
  66. 00 1010/0x0A = rrot
  67. 00 1011/0x0B = lrot
  68.  
  69. 01 0000/0x14 = and
  70. 01 0001/0x15 = or
  71. 01 0010/0x16 = xor
  72. 01 0011/0x17 = not
  73.  
  74. 01 1000/0x18 = equal
  75. 01 1001/0x19 = not equal
  76. 01 1010/0x20 = lessthan
  77. 01 1011/0x21 = morethan
  78. 01 1100/0x22 = lessthan or equal
  79. 01 1101/0x23 = morethan or equal
  80.  
  81. sourcedata = where the data is coming from
  82. 000/0 = value of <srcA> register
  83. 001/1 = value of <srcB> register
  84. 010/2 = value of <dst> register
  85. 011/3 = in-instruction-data (last 16 bits)
  86.  
  87. 100/4 = ram lookup (value of <srcA> register is address)
  88. 101/5 = ram lookup (last 16 bits is address)
  89.  
  90. 110/6 = output of ALU
  91.  
  92. 111/7 = instruction is nop
  93.  
  94. destdata = where the data is going to
  95. 00/0 = <dst> register
  96. 01/1 = ram (last 16 bits is address)
  97. 10/2 = ram (value of <srcA> register is address)
  98. 11/3 = program counter
  99.  
  100. conditional = whether or not the instruction has a condition
  101. 0 = instruction will always execute
  102. 1 = instruction will execute if value in <srcB> exceeds 0
  103.  
  104. == Instruction Opcodes ==
  105. == Data Transfer and Jumping ==
  106. MOVE <dst> <src> = 0 000 00 /00 = 0x00
  107. MOVE <dst> <value> = 0 011 00 /00 = 0x30
  108. LOAD <dst> <addr> = 0 101 00 /00 = 0x50
  109. LOAD <dst> <src> = 0 100 00 /00 = 0x40
  110. STORE <dst> <addr> = 0 010 01 /00 = 0x24
  111. STORE <dst> <src> = 0 010 10 /00 = 0x28
  112. JMP <addr> = 0 011 11 /00 = 0x3C
  113. JMP <dst> = 0 000 11 /00 = 0x0B
  114. NOOP = 0 111 00 /00 = 0x70
  115.  
  116. == Arithmetic and Logic ==
  117. ADD <dst> <srcA> <srcB> = 1 00 0000 /0 = 0x80
  118. SUB <dst> <srcA> <srcB> = 1 00 0001 /0 = 0x82
  119. MUL <dst> <srcA> <srcB> = 1 00 0010 /0 = 0x84
  120.  
  121. AND <dst> <srcA> <srcB> = 1 01 0000 /0 = 0x90
  122. OR <dst> <srcA> <srcB> = 1 01 0001 /0 = 0x92
  123. XOR <dst> <srcA> <srcB> = 1 01 0010 /0 = 0x94
  124. NOT <dst> <srcA> = 1 01 0011 /0 = 0x96
  125.  
  126. == Comparisons ==
  127. EQL <dst> <srcA> <srcB> 1 01 1000 /0 = 0xB0
  128. NEQL <dst> <srcA> <srcB> = 1 01 1001 /0 = 0xB2
  129. LESS <dst> <srcA> <srcB> = 1 01 1010 /0 = 0xB4
  130. MORE <dst> <srcA> <srcB> = 1 01 1011 /0 = 0xB6
  131. LEQL <dst> <srcA> <srcB> = 1 01 1100 /0 = 0xB8
  132. MEQL <dst> <srcA> <srcB> = 1 01 1100 /0 = 0xBA
  133.  
  134.  
  135. == Test Program ==
  136.  
  137. MOVE gp0 0x0002
  138. MOVE gp1 0x0006 CND GP0
  139.  
  140. 0x30000002
  141. 0x31100006
Advertisement
Add Comment
Please, Sign In to add comment