Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.79 KB | None | 0 0
  1. instruction encoding
  2.  
  3. control word encoding:
  4. ---------------------------------------------------------------------------------------------------------------------------------
  5. | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 |
  6. |-------------------------------------------------------------------------------------------------------------------------------|
  7. | Registers |
  8. |-------------------------------------------------------------------------------------------------------------------------------|
  9. | $x | $y | PC | CIR | MAR | MDR | Run | Opc | BP | SP |
  10. |-------------------------------------------------------------------------------------------------------------------------------|
  11. | I | O | I | O | I | O | I | I | I | O | I | O | I | O | I | O |
  12. ---------------------------------------------------------------------------------------------------------------------------------
  13.  
  14.  
  15. ---------------------------------------------------------------------------------------------------------------------------------
  16. | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
  17. |-------------------------------------------------------------------------------------------------------------------------------|
  18. | ALU inputs | ALU outputs | |
  19. |-----------------------------------------------------------------------------------------------------------------------| |
  20. | 1 | 2 | add | sub | inc | dec | not | and | or | xor | slt | srl | mult | div | rem | end |
  21. |-----------------------------------------------------------------------------------------------------------------------| |
  22. | I | I | O | O | O | O | O | O | O | O | O | O | O | O | O | |
  23. ---------------------------------------------------------------------------------------------------------------------------------
  24.  
  25.  
  26. bank[x] is shorthand for mem[$$bp * 16 + x]
  27.  
  28. add $x, $y
  29. encoding: 000000XY
  30. description: $x += $y
  31. microcode:
  32. xo alu1
  33. yo alu2
  34. add xi end
  35. 01000000000000001000000000000000
  36. 00010000000000000100000000000000
  37. 10000000000000000010000000000001
  38.  
  39. sub $x, $y
  40. encoding: 000001XY
  41. description: $x -= $y
  42. microcode:
  43. xo alu1
  44. yo alu2
  45. sub xi end
  46. 01000000000000001000000000000000
  47. 00010000000000000100000000000000
  48. 10000000000000000001000000000001
  49.  
  50. halt
  51. encoding: 00001000
  52. description: Stop execution
  53.  
  54. rst
  55. encoding: 00001001
  56. description: Set all the registers to 0, clear memory after program
  57.  
  58. brk $x
  59. encoding: 0000101X
  60. description: Write $x to the continuously-displayed 1-byte breakpoint buffer
  61. (and then start stepping through execution?)
  62.  
  63. inc $x
  64. encoding: 0000110X
  65. description: $x ++
  66. microcode:
  67. xo alu1
  68. inc xi end
  69. 01000000000000001000000000000000
  70. 10000000000000000000100000000001
  71.  
  72. dec $x
  73. encoding: 0000111X
  74. description: $x --
  75. microcode:
  76. xo alu1
  77. dec xi end
  78. 01000000000000001000000000000000
  79. 10000000000000000000010000000001
  80.  
  81. not $x, $y
  82. encoding: 000100XY
  83. description: $x = ~$y
  84. microcode:
  85. xo alu1
  86. not xi end
  87. 01000000000000001000000000000000
  88. 10000000000000000000001000000001
  89.  
  90. and $x, $y
  91. encoding: 000101XY
  92. description: $x &= $y
  93. microcode:
  94. xo alu1
  95. and xi end
  96. 01000000000000001000000000000000
  97. 10000000000000000000000100000001
  98.  
  99. or $x, $y
  100. encoding: 000110XY
  101. description: $x |= $y
  102. microcode:
  103. xo alu1
  104. or xi end
  105. 01000000000000001000000000000000
  106. 10000000000000000000000010000001
  107.  
  108. xor $x, $y
  109. encoding: 000111XY
  110. description: $x ^= $y
  111. microcode:
  112. xo alu1
  113. xor xi end
  114. 01000000000000001000000000000000
  115. 10000000000000000000000001000001
  116.  
  117. li $x, imm
  118. encoding: 001XIIII
  119. description: $x = imm
  120. microcode:
  121. opco xi end
  122. 10000000000100000000000000000001
  123.  
  124. slt $x, $y
  125. encoding: 010000XY
  126. description: $x = ($x < $y)
  127. microcode:
  128. xo alu1
  129. yo alu2
  130. slt xi end
  131. 01000000000000001000000000000000
  132. 00010000000000000100000000000000
  133. 10000000000000000000000000100001
  134.  
  135. srl $x, $y
  136. encoding: 010001XY
  137. description: $x >>= $y ($y signed)
  138. microcode:
  139. xo alu1
  140. yo alu2
  141. srl xi end
  142. 01000000000000001000000000000000
  143. 00010000000000000100000000000000
  144. 10000000000000000000000000010001
  145.  
  146. mult $x, $y
  147. encoding: 010010XY
  148. description: $x *= $y
  149. microcode:
  150. xo alu1
  151. yo alu2
  152. mult xi end
  153. 01000000000000001000000000000000
  154. 00010000000000000100000000000000
  155. 10000000000000000000000000001001
  156.  
  157. div $x, $y
  158. encoding: 010011XY
  159. description: $x /= $y
  160. microcode:
  161. xo alu1
  162. yo alu2
  163. div xi
  164. rem yi end
  165. 01000000000000001000000000000000
  166. 00010000000000000100000000000000
  167. 10000000000000000000000000000100
  168. 00100000000000000000000000000011
  169.  
  170. j imm
  171. encoding: 0101IIII
  172. description: $$pc = imm
  173. microcode:
  174. bpo opco pci end
  175. 00001000000101000000000000000001
  176.  
  177. jnez $x, imm
  178. encoding: 011XIIII
  179. description: if ($x) $$pc = imm
  180. microcode:
  181. bpo opco pci end
  182. 00001000000101000000000000000001
  183.  
  184. lw $x, [imm]
  185. encoding: 100XIIII
  186. description: $x = bank[imm]
  187. microcode:
  188. bpo opco mari
  189. mdro xi end
  190. 00000001000101000000000000000000
  191. 10000000010000000000000000000001
  192.  
  193. sw $x, [imm]
  194. encoding: 101XIIII
  195. description: bank[imm] = $x
  196. microcode:
  197. bpo opco mari
  198. xo mdri end
  199. 00000001000101000000000000000000
  200. 01000000100000000000000000000001
  201.  
  202. lw $x, [$y]
  203. encoding: 110000XY
  204. description: $x = mem[$y]
  205. microcode:
  206. yo mari
  207. mdro xi end
  208. 00010001000000000000000000000000
  209. 10000000010000000000000000000001
  210.  
  211. sw $x, [$y]
  212. encoding: 110001XY
  213. description: mem[$y] = $x
  214. microcode:
  215. yo mari
  216. xo mdri end
  217. 00010001000000000000000000000000
  218. 01000000100000000000000000000001
  219.  
  220. copy [$x], [$y]
  221. encoding: 110010XY
  222. description: mem[$x] = mem[$y]
  223. microcode:
  224. yo mari
  225. mdro yi
  226. xo mari
  227. yo mdri end
  228. 00010001000000000000000000000000
  229. 00100000010000000000000000000000
  230. 01000001000000000000000000000000
  231. 00010000100000000000000000000001
  232.  
  233. swap [$x], [$y]
  234. encoding: 110011XY
  235. description: tmp = mem[$x]; mem[$x] = mem[$y]; mem[$y] = tmp
  236. microcode:
  237. yo mari
  238. mdro alu1 alu2
  239. xo mari
  240. mdro xi
  241. and mdri
  242. yo mari
  243. xo mdri end
  244. 00010001000000000000000000000000
  245. 00000000010000001100000000000000
  246. 01000001000000000000000000000000
  247. 10000000010000000000000000000000
  248. 00000000100000000000000100000000
  249. 00010001000000000000000000000000
  250. 01000000100000000000000000000001
  251.  
  252. push $x
  253. encoding: 1101000X
  254. description: mem[$$sp] = $x; $$sp ++
  255. microcode:
  256. spo mari alu1
  257. xo mdri
  258. inc spi end
  259. 00000001000000011000000000000000
  260. 01000000100000000000000000000000
  261. 00000000000000100000100000000001
  262.  
  263. pop $x
  264. encoding: 1101001X
  265. description: $x = mem[$$sp]; $$sp --
  266. microcode:
  267. spo alu1
  268. dec spi mari
  269. mdro xi end
  270. 00000000000000011000000000000000
  271. 00000001000000100000010000000000
  272. 10000000010000000000000000000001
  273.  
  274. call $x
  275. encoding: 1101010X
  276. description: mem[$$sp] = $$pc; $$sp ++; $$pc = $x
  277. microcode:
  278. spo mari alu1
  279. pco mdri
  280. inc spi
  281. xo pci end
  282. 00000001000000011000000000000000
  283. 00000100100000000000000000000000
  284. 00000000000000100000100000000000
  285. 01001000000000000000000000000001
  286.  
  287. init
  288. encoding: 11010110
  289. description: $$sp = &bank[0] OR $$sp = $$bp * 16
  290. microcode:
  291. bpo spi end
  292. 00000000000001100000000000000001
  293.  
  294. rts
  295. encoding: 11010111
  296. description: $$pc = mem[$$sp]; $$sp --;
  297. microcode:
  298. spo alu1
  299. dec spi mari
  300. mdro pci end
  301. 00000000000000011000000000000000
  302. 00000001000000100000010000000000
  303. 00001000010000000000000000000001
  304.  
  305. push [$x$y]
  306. encoding: 110110XY
  307. description: mem[$$sp] = mem[$x * 16 + $y]; $$sp ++
  308.  
  309. pop [$x$y]
  310. encoding: 110111XY
  311. description: mem[$x$y] = mem[$$sp]; $$sp --
  312.  
  313. bnk $x
  314. encoding: 1110000X
  315. description: $$bp = $x
  316. microcode:
  317. xo bpi end
  318. 01000000000010000000000000000001
  319.  
  320. incb
  321. encoding: 11100010
  322. description: $$bp ++
  323. microcode:
  324. bpo alu1
  325. inc bpi end
  326. 00000000000001001000000000000000
  327. 00000000000010000000100000000001
  328.  
  329. decb
  330. encoding: 11100011
  331. description: $$bp --
  332. microcode:
  333. bpo alu1
  334. dec bpi end
  335. 00000000000001001000000000000000
  336. 00000000000010000000010000000001
  337.  
  338. addb $x
  339. encoding: 1110010X
  340. description: $$bp += $x
  341. microcode:
  342. bpo alu1
  343. xo alu2
  344. add bpi end
  345. 00000000000001001000000000000000
  346. 01000000000000000100000000000000
  347. 00000000000010000010000000000001
  348.  
  349. subb $x
  350. encoding: 1110011X
  351. description: $$bp -= $x
  352. microcode:
  353. bpo alu1
  354. xo alu2
  355. sub bpi end
  356. 00000000000001001000000000000000
  357. 01000000000000000100000000000000
  358. 00000000000010000001000000000001
  359.  
  360. bnki imm
  361. encoding: 11101III
  362. description: $$bp = imm
  363. microcode:
  364. opco bpi end
  365. 00000000000110000000000000000001
  366.  
  367. IO stuff:
  368.  
  369. ???
  370. encoding: 111100XY
  371.  
  372. ???
  373. encoding: 111101XY
  374.  
  375. ???
  376. encoding: 111110XY
  377.  
  378. ???
  379. encoding: 111111XY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement