knight-native_defs.M1 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. ## Copyright (C) 2016 Jeremiah Orians
  2. ## This file is part of stage0.
  3. ##
  4. ## stage0 is free software: you can redistribute it and/or modify
  5. ## it under the terms of the GNU General Public License as published by
  6. ## the Free Software Foundation, either version 3 of the License, or
  7. ## (at your option) any later version.
  8. ##
  9. ## stage0 is distributed in the hope that it will be useful,
  10. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ## GNU General Public License for more details.
  13. ##
  14. ## You should have received a copy of the GNU General Public License
  15. ## along with stage0. If not, see <http://www.gnu.org/licenses/>.
  16. #Registers
  17. DEFINE R0 0
  18. DEFINE R1 1
  19. DEFINE R2 2
  20. DEFINE R3 3
  21. DEFINE R4 4
  22. DEFINE R5 5
  23. DEFINE R6 6
  24. DEFINE R7 7
  25. DEFINE R8 8
  26. DEFINE R9 9
  27. DEFINE R10 A
  28. DEFINE R11 B
  29. DEFINE R12 C
  30. DEFINE R13 D
  31. DEFINE R14 E
  32. DEFINE R15 F
  33. # 4OP Integer Group
  34. DEFINE ADD.CI 0100
  35. DEFINE ADD.CO 0101
  36. DEFINE ADD.CIO 0102
  37. DEFINE ADDU.CI 0103
  38. DEFINE ADDU.CO 0104
  39. DEFINE ADDU.CIO 0105
  40. DEFINE SUB.BI 0106
  41. DEFINE SUB.BO 0107
  42. DEFINE SUB.BIO 0108
  43. DEFINE SUBU.BI 0109
  44. DEFINE SUBU.BO 010A
  45. DEFINE SUBU.BIO 010B
  46. DEFINE MULTIPLY 010C
  47. DEFINE MULTIPLYU 010D
  48. DEFINE DIVIDE 010E
  49. DEFINE DIVIDEU 010F
  50. DEFINE MUX 0110
  51. DEFINE NMUX 0111
  52. DEFINE SORT 0112
  53. DEFINE SORTU 0113
  54. # 3OP Integer Group
  55. DEFINE ADD 05000
  56. DEFINE ADDU 05001
  57. DEFINE SUB 05002
  58. DEFINE SUBU 05003
  59. DEFINE CMP 05004
  60. DEFINE CMPU 05005
  61. DEFINE MUL 05006
  62. DEFINE MULH 05007
  63. DEFINE MULU 05008
  64. DEFINE MULUH 05009
  65. DEFINE DIV 0500A
  66. DEFINE MOD 0500B
  67. DEFINE DIVU 0500C
  68. DEFINE MODU 0500D
  69. DEFINE MAX 05010
  70. DEFINE MAXU 05011
  71. DEFINE MIN 05012
  72. DEFINE MINU 05013
  73. DEFINE AND 05020
  74. DEFINE OR 05021
  75. DEFINE XOR 05022
  76. DEFINE NAND 05023
  77. DEFINE NOR 05024
  78. DEFINE XNOR 05025
  79. DEFINE MPQ 05026
  80. DEFINE LPQ 05027
  81. DEFINE CPQ 05028
  82. DEFINE BPQ 05029
  83. DEFINE SAL 05030
  84. DEFINE SAR 05031
  85. DEFINE SL0 05032
  86. DEFINE SR0 05033
  87. DEFINE SL1 05034
  88. DEFINE SR1 05035
  89. DEFINE ROL 05036
  90. DEFINE ROR 05037
  91. DEFINE LOADX 05038
  92. DEFINE LOADX8 05039
  93. DEFINE LOADXU8 0503A
  94. DEFINE LOADX16 0503B
  95. DEFINE LOADXU16 0503C
  96. DEFINE LOADX32 0503D
  97. DEFINE LOADXU32 0503E
  98. DEFINE STOREX 05048
  99. DEFINE STOREX8 05049
  100. DEFINE STOREX16 0504A
  101. DEFINE STOREX32 0504B
  102. DEFINE CMPJUMP.G 05050
  103. DEFINE CMPJUMP.GE 05051
  104. DEFINE CMPJUMP.E 05052
  105. DEFINE CMPJUMP.NE 05053
  106. DEFINE CMPJUMP.LE 05054
  107. DEFINE CMPJUMP.L 05055
  108. DEFINE CMPJUMPU.G 05060
  109. DEFINE CMPJUMPU.GE 05061
  110. DEFINE CMPJUMPU.LE 05064
  111. DEFINE CMPJUMPU.L 05065
  112. # 2OP Integer Group
  113. DEFINE NEG 090000
  114. DEFINE ABS 090001
  115. DEFINE NABS 090002
  116. DEFINE SWAP 090003
  117. DEFINE COPY 090004
  118. DEFINE MOVE 090005
  119. DEFINE NOT 090006
  120. DEFINE BRANCH 090100
  121. DEFINE CALL 090101
  122. DEFINE PUSHR 090200
  123. DEFINE PUSH8 090201
  124. DEFINE PUSH16 090202
  125. DEFINE PUSH32 090203
  126. DEFINE POPR 090280
  127. DEFINE POP8 090281
  128. DEFINE POPU8 090282
  129. DEFINE POP16 090283
  130. DEFINE POPU16 090284
  131. DEFINE POP32 090285
  132. DEFINE POPU32 090286
  133. DEFINE CMPSKIP.G 090300
  134. DEFINE CMPSKIP.GE 090301
  135. DEFINE CMPSKIP.E 090302
  136. DEFINE CMPSKIP.NE 090303
  137. DEFINE CMPSKIP.LE 090304
  138. DEFINE CMPSKIP.L 090305
  139. DEFINE CMPSKIPU.G 090380
  140. DEFINE CMPSKIPU.GE 090381
  141. DEFINE CMPSKIPU.LE 090384
  142. DEFINE CMPSKIPU.L 090385
  143. # 1OP Group
  144. DEFINE READPC 0D00000
  145. DEFINE READSCID 0D00001
  146. DEFINE FALSE 0D00002
  147. DEFINE TRUE 0D00003
  148. DEFINE JSR_COROUTINE 0D01000
  149. DEFINE RET 0D01001
  150. DEFINE PUSHPC 0D02000
  151. DEFINE POPPC 0D02001
  152. # 2OPI Group
  153. DEFINE SET.G E10000
  154. DEFINE SET.GE E10001
  155. DEFINE SET.E E10002
  156. DEFINE SET.NE E10003
  157. DEFINE SET.LE E10004
  158. DEFINE SET.L E10005
  159. DEFINE ADDI E1000E
  160. DEFINE ADDUI E1000F
  161. DEFINE SUBI E10010
  162. DEFINE SUBUI E10011
  163. DEFINE CMPI E10012
  164. DEFINE LOAD E10013
  165. DEFINE LOAD8 E10014
  166. DEFINE LOADU8 E10015
  167. DEFINE LOAD16 E10016
  168. DEFINE LOADU16 E10017
  169. DEFINE LOAD32 E10018
  170. DEFINE LOADU32 E10019
  171. DEFINE CMPUI E1001F
  172. DEFINE STORE E10020
  173. DEFINE STORE8 E10021
  174. DEFINE STORE16 E10022
  175. DEFINE STORE32 E10023
  176. DEFINE ANDI E100B0
  177. DEFINE ORI E100B1
  178. DEFINE XORI E100B2
  179. DEFINE NANDI E100B3
  180. DEFINE NORI E100B4
  181. DEFINE XNORI E100B5
  182. DEFINE CMPJUMPI.G E100C0
  183. DEFINE CMPJUMPI.GE E100C1
  184. DEFINE CMPJUMPI.E E100C2
  185. DEFINE CMPJUMPI.NE E100C3
  186. DEFINE CMPJUMPI.LE E100C4
  187. DEFINE CMPJUMPI.L E100C5
  188. DEFINE CMPJUMPUI.G E100D0
  189. DEFINE CMPJUMPUI.GE E100D1
  190. DEFINE CMPJUMPUI.LE E100D4
  191. DEFINE CMPJUMPUI.L E100D5
  192. # 1OPI Group
  193. DEFINE JUMP.C E0002C0
  194. DEFINE JUMP.B E0002C1
  195. DEFINE JUMP.O E0002C2
  196. DEFINE JUMP.G E0002C3
  197. DEFINE JUMP.GE E0002C4
  198. DEFINE JUMP.E E0002C5
  199. DEFINE JUMP.NE E0002C6
  200. DEFINE JUMP.LE E0002C7
  201. DEFINE JUMP.L E0002C8
  202. DEFINE JUMP.Z E0002C9
  203. DEFINE JUMP.NZ E0002CA
  204. DEFINE JUMP.P E0002CB
  205. DEFINE JUMP.NP E0002CC
  206. DEFINE CALLI E0002D0
  207. DEFINE LOADI E0002D1
  208. DEFINE LOADUI E0002D2
  209. DEFINE SALI E0002D3
  210. DEFINE SARI E0002D4
  211. DEFINE SL0I E0002D5
  212. DEFINE SR0I E0002D6
  213. DEFINE SL1I E0002D7
  214. DEFINE SR1I E0002D8
  215. DEFINE LOADR E0002E0
  216. DEFINE LOADR8 E0002E1
  217. DEFINE LOADRU8 E0002E2
  218. DEFINE LOADR16 E0002E3
  219. DEFINE LOADRU16 E0002E4
  220. DEFINE LOADR32 E0002E5
  221. DEFINE LOADRU32 E0002E6
  222. DEFINE STORER E0002F0
  223. DEFINE STORER8 E0002F1
  224. DEFINE STORER16 E0002F2
  225. DEFINE STORER32 E0002F3
  226. DEFINE CMPSKIPI.G E000A00
  227. DEFINE CMPSKIPI.GE E000A01
  228. DEFINE CMPSKIPI.E E000A02
  229. DEFINE CMPSKIPI.NE E000A03
  230. DEFINE CMPSKIPI.LE E000A04
  231. DEFINE CMPSKIPI.L E000A05
  232. DEFINE CMPSKIPUI.G E000A10
  233. DEFINE CMPSKIPUI.GE E000A11
  234. DEFINE CMPSKIPUI.LE E000A14
  235. DEFINE CMPSKIPUI.L E000A15
  236. # 0OPI Group
  237. DEFINE JUMP 3C00
  238. # HALCODE Group
  239. DEFINE FOPEN_READ 42100000
  240. DEFINE FOPEN_WRITE 42100001
  241. DEFINE FCLOSE 42100002
  242. DEFINE REWIND 42100003
  243. DEFINE FSEEK 42100004
  244. DEFINE FGETC 42100100
  245. DEFINE FPUTC 42100200
  246. DEFINE HAL_MEM 42110000
  247. # 0OP Group
  248. DEFINE NULL 00000000
  249. DEFINE HALT FFFFFFFF