Advertisement
Jhynjhiruu

Untitled

Feb 17th, 2020
1,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.00 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 | mall | end |
  21. |---------------------------------------------------------------------------------------------------------------| | |
  22. | I | I | 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. microcode:
  54. runi end
  55. 00000000001000000000000000000001
  56.  
  57. rst
  58. encoding: 00001001
  59. description: Set all the registers to 0, clear memory after program
  60. microcode:
  61. xi yi pci bpi spi alu1 alu2 mdri mari end
  62. 10101001100010101100000000000001
  63.  
  64. brk $x
  65. encoding: 0000101X
  66. description: Write $x to the continuously-displayed 1-byte breakpoint buffer
  67. (and then start stepping through execution?)
  68.  
  69. inc $x
  70. encoding: 0000110X
  71. description: $x ++
  72. microcode:
  73. xo alu1
  74. inc xi end
  75. 01000000000000001000000000000000
  76. 10000000000000000000100000000001
  77.  
  78. dec $x
  79. encoding: 0000111X
  80. description: $x --
  81. microcode:
  82. xo alu1
  83. dec xi end
  84. 01000000000000001000000000000000
  85. 10000000000000000000010000000001
  86.  
  87. not $x, $y
  88. encoding: 000100XY
  89. description: $x = ~$y
  90. microcode:
  91. xo alu1
  92. yo alu2
  93. not xi end
  94. 01000000000000001000000000000000
  95. 00010000000000000100000000000000
  96. 10000000000000000000001000000001
  97.  
  98. and $x, $y
  99. encoding: 000101XY
  100. description: $x &= $y
  101. microcode:
  102. xo alu1
  103. yo alu2
  104. and xi end
  105. 01000000000000001000000000000000
  106. 00010000000000000100000000000000
  107. 10000000000000000000000100000001
  108.  
  109. or $x, $y
  110. encoding: 000110XY
  111. description: $x |= $y
  112. microcode:
  113. xo alu1
  114. yo alu2
  115. or xi end
  116. 01000000000000001000000000000000
  117. 00010000000000000100000000000000
  118. 10000000000000000000000010000001
  119.  
  120. xor $x, $y
  121. encoding: 000111XY
  122. description: $x ^= $y
  123. microcode:
  124. xo alu1
  125. yo alu2
  126. xor xi end
  127. 01000000000000001000000000000000
  128. 00010000000000000100000000000000
  129. 10000000000000000000000001000001
  130.  
  131. li $x, imm
  132. encoding: 001XIIII
  133. description: $x = imm
  134. microcode:
  135. opco xi end
  136. 10000000000100000000000000000001
  137.  
  138. slt $x, $y
  139. encoding: 010000XY
  140. description: $x = ($x < $y)
  141. microcode:
  142. xo alu1
  143. yo alu2
  144. slt xi end
  145. 01000000000000001000000000000000
  146. 00010000000000000100000000000000
  147. 10000000000000000000000000100001
  148.  
  149. srl $x, $y
  150. encoding: 010001XY
  151. description: $x >>= $y ($y signed)
  152. microcode:
  153. xo alu1
  154. yo alu2
  155. srl xi end
  156. 01000000000000001000000000000000
  157. 00010000000000000100000000000000
  158. 10000000000000000000000000010001
  159.  
  160. mult $x, $y
  161. encoding: 010010XY
  162. description: $x *= $y
  163. microcode:
  164. xo alu1
  165. yo alu2
  166. mult xi end
  167. 01000000000000001000000000000000
  168. 00010000000000000100000000000000
  169. 10000000000000000000000000001001
  170.  
  171. div $x, $y
  172. encoding: 010011XY
  173. description: $x /= $y
  174. microcode:
  175. xo alu1
  176. yo alu2
  177. div xi end
  178. 01000000000000001000000000000000
  179. 00010000000000000100000000000000
  180. 10000000000000000000000000000101
  181.  
  182. j imm
  183. encoding: 0101IIII
  184. description: $$pc = imm
  185. microcode:
  186. bpo opco pci end
  187. 00001000000101000000000000000001
  188.  
  189. jnez $x, imm
  190. encoding: 011XIIII
  191. description: if ($x) $$pc = imm
  192. microcode:
  193. bpo opco pci end
  194. 00001000000101000000000000000001
  195.  
  196. lw $x, [imm]
  197. encoding: 100XIIII
  198. description: $x = bank[imm]
  199. microcode:
  200. bpo opco mari
  201. mdro xi end
  202. 00000001000101000000000000000000
  203. 10000000010000000000000000000001
  204.  
  205. sw $x, [imm]
  206. encoding: 101XIIII
  207. description: bank[imm] = $x
  208. microcode:
  209. bpo opco mari
  210. xo mdri end
  211. 00000001000101000000000000000000
  212. 01000000100000000000000000000001
  213.  
  214. lw $x, [$y]
  215. encoding: 110000XY
  216. description: $x = mem[$y]
  217. microcode:
  218. yo mari
  219. mdro xi end
  220. 00010001000000000000000000000000
  221. 10000000010000000000000000000001
  222.  
  223. sw $x, [$y]
  224. encoding: 110001XY
  225. description: mem[$y] = $x
  226. microcode:
  227. yo mari
  228. xo mdri end
  229. 00010001000000000000000000000000
  230. 01000000100000000000000000000001
  231.  
  232. copy [$x], [$y]
  233. encoding: 110010XY
  234. description: mem[$x] = mem[$y]
  235. microcode:
  236. yo mari
  237. mdro alu1 alu2
  238. xo mari
  239. mdri and end
  240. 00010001000000000000000000000000
  241. 00000000010000001100000000000000
  242. 01000001000000000000000000000000
  243. 00000000100000000000000100000001
  244.  
  245. swap [$x], [$y]
  246. encoding: 110011XY
  247. description: tmp = mem[$x]; mem[$x] = mem[$y]; mem[$y] = tmp
  248. microcode:
  249. xo mari
  250. mdro alu1
  251. yo mari
  252. mdro alu2
  253. xor alu1
  254. xor mdri alu2
  255. xo mari
  256. xor mdri end
  257. 01000001000000000000000000000000
  258. 00000000010000001000000000000000
  259. 00010001000000000000000000000000
  260. 00000000010000000100000000000000
  261. 00000000000000001000000001000000
  262. 00000000100000000100000001000000
  263. 01000001000000000000000000000000
  264. 00000000100000000000000001000001
  265.  
  266. push $x
  267. encoding: 1101000X
  268. description: mem[$$sp] = $x; $$sp ++
  269. microcode:
  270. spo alu1
  271. inc spi mari
  272. mdri xo end
  273. 00000000000000011000000000000000
  274. 00000001000000100000100000000000
  275. 01000000100000000000000000000001
  276.  
  277. pop $x
  278. encoding: 1101001X
  279. description: $x = mem[$$sp]; $$sp --
  280. microcode:
  281. spo mari alu1
  282. xi mdro
  283. dec spi end
  284. 00000001000000011000000000000000
  285. 10000000010000000000000000000000
  286. 00000000000000100000010000000001
  287.  
  288. call $x
  289. encoding: 1101010X
  290. description: mem[$$sp] = $$pc; $$sp ++; $$pc = $x
  291. microcode:
  292. spo alu1
  293. inc spi mari
  294. pco mdri
  295. xo pci end
  296. 00000000000000011000000000000000
  297. 00000001000000100000100000000000
  298. 00000100100000000000000000000000
  299. 01001000000000000000000000000001
  300.  
  301. init
  302. encoding: 11010110
  303. description: $$sp = &bank[0] OR $$sp = $$bp * 16
  304. microcode:
  305. bpo spi end
  306. 00000000000001100000000000000001
  307.  
  308. rts
  309. encoding: 11010111
  310. description: $$pc = mem[$$sp]; $$sp --;
  311. microcode:
  312. spo mari alu1
  313. dec spi
  314. mdro pci end
  315. 00000001000000011000000000000000
  316. 00000000000000100000010000000000
  317. 00001000010000000000000000000001
  318.  
  319. ???
  320. encoding: 110110XY
  321. description:
  322.  
  323. ???
  324. encoding: 110111XY
  325. description:
  326.  
  327. bnk $x
  328. encoding: 1110000X
  329. description: $$bp = $x
  330. microcode:
  331. xo bpi end
  332. 01000000000010000000000000000001
  333.  
  334. incb
  335. encoding: 11100010
  336. description: $$bp ++
  337. microcode:
  338. bpo alu1
  339. inc bpi end
  340. 00000000000001001000000000000000
  341. 00000000000010000000100000000001
  342.  
  343. decb
  344. encoding: 11100011
  345. description: $$bp --
  346. microcode:
  347. bpo alu1
  348. dec bpi end
  349. 00000000000001001000000000000000
  350. 00000000000010000000010000000001
  351.  
  352. addb $x
  353. encoding: 1110010X
  354. description: $$bp += $x
  355. microcode:
  356. bpo alu1
  357. xo alu2
  358. add bpi end
  359. 00000000000001001000000000000000
  360. 01000000000000000100000000000000
  361. 00000000000010000010000000000001
  362.  
  363. subb $x
  364. encoding: 1110011X
  365. description: $$bp -= $x
  366. microcode:
  367. bpo alu1
  368. xo alu2
  369. sub bpi end
  370. 00000000000001001000000000000000
  371. 01000000000000000100000000000000
  372. 00000000000010000001000000000001
  373.  
  374. ???
  375. encoding: 111010XY
  376. description:
  377.  
  378. ???
  379. encoding: 111011XY
  380. description:
  381.  
  382. bnki imm
  383. encoding: 1111IIII
  384. description: $$bp = imm
  385. microcode:
  386. opco bpi end
  387. 00000000000110000000000000000001
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement