Advertisement
Ham62

Opcodes

Mar 13th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. *******************************
  2. * Normal CPU operations *
  3. *******************************
  4. 0000 -- NOP (Comments)
  5. Offset 2, WORD: Length of comment
  6. Offset 4, WORD: Location of coment in array
  7. Offset 6, WORD: ignored
  8.  
  9. 0001 -- Allocate for single precision number
  10. Offset 2, WORD: Location of name in array
  11. Offset 4, DWORD: Actual single
  12.  
  13. 0002 -- Allocate for string
  14. Offset 2, WORD: location of name in array
  15. Offset 4, WORD: location of string in array
  16. Offset 6, WORD: ignored
  17.  
  18. 0003 -- dispatch (GOTO/GOSUB/RETURN/etc.)
  19. Offset 2, WORD: Type of jump (0 = GOTO/JMP || 1 = GOSUB/CALL || 2 = RETURN)
  20. Offset 4, WORD: Instruction to jump to
  21. Offset 6, WORD: ignored
  22.  
  23. 0004 -- IF= (IF A = B)
  24. Offset 2, WORD: Location of variable A
  25. Offset 4, WORD: Location of variable B
  26. Offset 6, WORD: Instruction to jump to
  27.  
  28. 0005 -- IF> (IF A > B)
  29. Offset 2, WORD: Location of variable A
  30. Offset 4, WORD: Location of variable B
  31. Offset 6, WORD: Instruction to jump to
  32.  
  33. 0006 -- IF< (IF A < B)
  34. Offset 2, WORD: Location of variable A
  35. Offset 4, WORD: Location of variable B
  36. Offset 6, WORD: Instruction to jump to
  37.  
  38. 0007 -- IF<> (IF A <> B)
  39. Offset 2, WORD: Location of variable A
  40. Offset 4, WORD: Location of variable B
  41. Offset 6, WORD: Instruction to jump to
  42.  
  43. 0008 -- LET (LET A = B)
  44. Offset 2, WORD: Location of variable A
  45. Offset 4, WORD: Location of variable B
  46. Offset 6, WORD: ignored
  47.  
  48. 0009 -- LET (LET A = constant)
  49. Offset 2, WORD: Location of variable A
  50. Offset 4, DWORD: Integer/single constant
  51.  
  52. 000A -- ADD A,B (A += B)
  53. Offset 2, WORD: Location of variable A
  54. Offset 4, WORD: Location of variable B
  55. Offset 6, WORD: ignored
  56.  
  57. 000B -- SUB A,B (A -= B)
  58. Offset 2, WORD: Location of variable A
  59. Offset 4, WORD: Location of variable B
  60. Offset 6, WORD: ignored
  61.  
  62. 000C -- MUL A,B (A *= B)
  63. Offset 2, WORD: Location of variable A
  64. Offset 4, WORD: Location of variable B
  65. Offset 6, WORD: ignored
  66.  
  67. 000D -- DIV A,B (A /= B)
  68. Offset 2, WORD: Location of variable A
  69. Offset 4, WORD: Location of variable B
  70. Offset 6, WORD: ignored
  71.  
  72. 000E -- ADD A,x (A += constant)
  73. Offset 2, WORD: Location of variable A
  74. Offset 4, DWORD: Integer constant to add
  75.  
  76. 000F -- SUB A,x (A -= constant)
  77. Offset 2, WORD: Location of variable A
  78. Offset 4, DWORD: Integer constant to subtract
  79.  
  80. 0010 -- MUL A,x (A *= constant)
  81. Offset 2, WORD: Location of variable A
  82. Offset 4, DWORD: Integer constant to multiply
  83.  
  84. 0011 -- DIV A,x (A /= constant)
  85. Offset 2, WORD: Location of variable A
  86. Offset 4, DWORD: Integer constant to divide
  87.  
  88. 0012 -- RND (x = Rnd(A to B))
  89. Offset 2, WORD: Location of variable x (Where to save?)
  90. Offset 4, WORD: Location of variable A (minimum)
  91. Offset 6, WORD: Location of variable B (maximum)
  92.  
  93. 0013 -- Round
  94. Offset 2, WORD: Offset of variable to round into
  95. Offset 4, WORD: Offset of variable to round
  96. Offset 6, WORD: Offset of variable holding decimals to round to
  97.  
  98. 0014 -- PUSH x (push variable offset to stack, adjust stack pointer)
  99. Offset 2, WORD: Type of PUSH (0 = constant || 1 = variable)
  100. Offset 4, WORD: Offset of variable to push to stack
  101. Offset 4, DWORD: Constant float value to push to stack
  102.  
  103. 0015 -- POP x (read variable offset from stack, adjust stack pointer)
  104. Offset 2, WORD: Offset of variable to read WORD of stack into
  105. Offset 4, DWORD: ignored
  106.  
  107. 0016 -- SRead (reads 2 bytes from stack, does not move stack pointer)
  108. Offset 2, WORD: Size of read (0 = WORD || 1 = DWORD)
  109. Offset 4, WORD: Offset of variable to read data into
  110. Offset 6, WORD: Offset (in WORDs) of stack to read data from
  111.  
  112. *******************************
  113. * BIOS Calls *
  114. *******************************
  115. 1000 -- End (Shuts down robot and stopps executing code)
  116. Offset 2, WORD: Shutdown code
  117. Offset 4, DWORD: ignored
  118.  
  119. 1001 -- Print (Write to debug console)
  120. Offset 2, WORD: Type of print (0 = Variable in bytecode || 1 = String in String Buffer)
  121. Offset 4, WORD: Location of string in array
  122. Offset 6, WORD: ignored
  123.  
  124. 1002 -- Move (Tells motors to move forward or back)
  125. Offset 2, WORD: Type of value passed (0 = constant, FFFF = variable)
  126. Offset 4, DWORD: Float constant for direction (positive = forward || negative = back)
  127. Offset 4, WORD: Offset of direction variable (positive = forward || negative = back)
  128.  
  129. 1003 -- Turn (Tells the motors the direction to rotate the bot)
  130. Offset 2, WORD: Type of value passed (0 = constant, FFFF = variable)
  131. Offset 4, DWORD: Float constant for direction (positive = right || negative = left)
  132. Offset 4, WORD: Offset of direction variable (positive = right || negative = left)
  133.  
  134. 1004 -- Read Sensor (Pulses a sensor on the robot to tell you how far you are from an object)
  135. Offset 2, WORD: Variable to save the result into
  136. Offset 4, WORD: Variable with sensor number to read
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement