Advertisement
Auios

Untitled

Oct 20th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. <===========================>
  2. <===== Project AuR_ASM =====>
  3. <===========================>
  4. | 16bit Architecture for a Virtual CPU Simulator
  5. | using the .Net v4.7 framework.
  6. |
  7. | Features include simple keyboard input and simple output
  8. | to a virtual screen.
  9. | Intended use is for educational purposes to explore,
  10. | learn, and understand: assembly language, assemblers,
  11. | machine code, how CPUs work, and why explorer.exe keeps crashing.
  12.  
  13.  
  14. <====================>
  15. <===== Notation =====>
  16. <====================>
  17. | <reg> - Any register (r0 - r11)
  18. | <val> - Any 32bit constant value
  19. | <mem> - Any 32bit memory address
  20.  
  21. <=====================>
  22. <===== Registers =====>
  23. <=====================>
  24. | Registers use 4bit addressing
  25.  
  26. === Register Addresses: (16 Registers) ===
  27. 0 r0
  28. 1 r1
  29. 2 r2
  30. 3 r3
  31. 4 r4
  32. 5 r5
  33. 6 r6
  34. 7 r7
  35. 8 r8
  36. 9 r9
  37. 10 r10
  38. 11 r11
  39. 12 Base Pointer (BP)
  40. 13 Stack Pointer (SP)
  41. 14 Control Register (CR)
  42. 15 Instruction Pointer (IP)
  43.  
  44. === Control Register Flag Bits ===
  45. 0 Carry Flag (CF)
  46. 1 Zero Flag (ZF)
  47. 2 Test Flag (TF)
  48. 3 Sign Flag (SF)
  49. 4 Interrupt Flag (IF)
  50. 5
  51. 6
  52. 7
  53. 8
  54. 9
  55. 10
  56. 11
  57. 12
  58. 13
  59. 14
  60. 15
  61.  
  62.  
  63. <===========================>
  64. <===== Instruction Codes ===>
  65. <===========================>
  66. | Using any instruction that doesn't have a function
  67. | will result in the program terminating
  68. | Instruction set uses 8bit addressing
  69.  
  70. === MISC ===
  71.  
  72. 0 - HALT
  73. 1 -
  74. 2 -
  75. 3 -
  76. 4 -
  77. 5 -
  78. 6 -
  79. 7 -
  80. 8 -
  81. 9 -
  82. 10 -
  83. 11 -
  84. 12 -
  85. 13 -
  86. 14 -
  87. 15 -
  88. 16 - SYS <reg>
  89. 17 - SYS <val>
  90. 18 -
  91. 19 -
  92. 20 -
  93. 21 -
  94. 22 -
  95. 23 -
  96. 24 -
  97. 25 -
  98. 26 -
  99. 27 -
  100. 28 -
  101. 29 -
  102. 30 -
  103. 31 -
  104.  
  105. === Logic ===
  106. | Modifies ZF
  107. | Returns result to left operand
  108.  
  109. 32 - AND <reg>, <reg>
  110. 33 - AND <reg>, <val>
  111.  
  112. 34 - OR <reg>, <reg>
  113. 35 - OR <reg>, <val>
  114.  
  115. 36 - XOR <reg>, <reg>
  116. 37 - XOR <reg>, <val>
  117.  
  118. 38 - NOT <reg>
  119.  
  120. === Arithmetic ===
  121. | Modifies CF and ZF
  122. | Returns result to left operand
  123.  
  124. 40 - ADD <reg>, <reg>
  125. 41 - SUB <reg>, <reg>
  126. 42 - MUL <reg>, <reg>
  127. 43 - DIV <reg>, <reg> (left = Quotient, right = Remainder)
  128.  
  129. === Memory ===
  130.  
  131. 48 - MOV <reg>, <reg>
  132. 49 - MOV <reg>, <val>
  133.  
  134. 50 - INC <reg>
  135. 51 - DEC <reg>
  136.  
  137. 52 - SHL <reg>
  138. 53 - SHL <reg>, <reg> (Result goes into left operand)
  139. 54 - SHL <reg>, <val> (Result goes into left operand)
  140.  
  141. 55 - SHR <reg>
  142. 56 - SHR <reg>, <reg> (Result goes into left operand)
  143. 57 - SHR <reg>, <val> (Result goes into left operand)
  144.  
  145. 64 - R8 <reg>, <mem>
  146. 65 - R16 <reg>, <mem>
  147. 66 - R32 <reg>, <mem>
  148.  
  149. 67 - W8 <reg>, <mem>
  150. 68 - W16 <reg>, <mem>
  151. 69 - W32 <reg>, <mem>
  152.  
  153. 70 - PUSH <reg>
  154. 71 - POP <reg>
  155.  
  156. === Compare ===
  157. | Modifies TF
  158.  
  159. 80 - TEST <reg> = <reg>
  160. 81 - TEST <reg> = <val>
  161.  
  162. 82 - TEST <reg> < <reg>
  163. 83 - TEST <reg> < <val>
  164.  
  165. 84 - TEST <reg> > <reg>
  166. 85 - TEST <reg> > <val>
  167.  
  168. 86 - TEST <reg> <= <reg>
  169. 87 - TEST <reg> <= <val>
  170.  
  171. 88 - TEST <reg> >= <reg>
  172. 89 - TEST <reg> >= <val>
  173.  
  174. === Jump ===
  175. | Checks TF
  176.  
  177. 100 - JMP <reg>
  178. 101 - JMP <mem>
  179. 102 - JMP <val>
  180.  
  181. 103 - JT <reg>
  182. 104 - JT <mem>
  183. 105 - JT <val>
  184.  
  185. 106 - JF <reg>
  186. 107 - JF <mem>
  187. 108 - JF <val>
  188.  
  189. === Call ===
  190. | Pushes current position + 1 onto the call stack before
  191. | jumping to specified address
  192.  
  193. 128 - RET
  194.  
  195. 129 - CALL <reg>
  196. 130 - CALL <mem>
  197. 131 - CALL <val>
  198.  
  199.  
  200. <========================>
  201. <===== System Calls =====>
  202. <========================>
  203. |
  204.  
  205. Hex | --------- Name -------------- | - Registers ----------------------------- +
  206. --- | ----------------------------- | -- r0 -- | -- r1 -- | -- r2 -- | -- r3 -- |
  207. __ | 0 - | | | | | (Nothing)
  208. __ | 10 - Enable/Disable Scrn | Bool | | | | (Turns the screen on/off)
  209. __ | 11 - Clear Screen | | | | | (Resets the screen to blank state)
  210. __ | 12 - Read input | KeyCode | | | | (Reads a byte from the input buffer)
  211. __ | 32 - Set Pixel | X | Y | ColorID | | (Sets pixel at X,Y to whatever the color code value is in r2)
  212. __ | 33 - Get Pixel Color | X | Y | ColorID | | (Returns pixel color at X,Y to r2)
  213. __ | 36 - SetPrint Char | X | Y | PrintID | | (Blockland Only)
  214. __ | 37 - GetPrint Char | X | Y | PrintID | | (Blockland Only)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement