stage1_assembler-2.hex2 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. ## Copyright (C) 2016 Jeremiah Orians
  2. ## This file is part of stage0.
  3. ##
  4. ## stage0 is free software: you an 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. :start
  17. 2D2D @table # LOADUI R13 @table ; Where we are putting our table
  18. # ;; We will be using R14 for our condition codes
  19. 2D2F7fff # LOADUI R15 0x7FFF ; We will be using R15 for our stack
  20. # ;; Main program functionality
  21. # ;; Reads in Tape_01 and writes out results onto Tape_02
  22. # ;; Accepts no arguments and HALTS when done
  23. :main
  24. # ;; Prep TAPE_01
  25. 2D201100 # LOADUI R0 0x1100
  26. 42100000 # FOPEN_READ
  27. # ;; Intialize environment
  28. 0D00002C # FALSE R12 ; Set holder to zero
  29. 0D00002B # FALSE R11 ; Set PC counter to zero
  30. 2D2A0001 # LOADUI R10 1 ; Our toggle
  31. # ;; Perform first pass
  32. 2D0F @first_pass # CALLI R15 @first_pass
  33. # ;; We need to rewind tape_01 to perform our second pass
  34. 2D201100 # LOADUI R0 0x1100
  35. 42100003 # REWIND
  36. # ;; Reintialize environment
  37. 0D00002C # FALSE R12 ; Set holder to zero
  38. 0D00002B # FALSE R11 ; Set PC counter to zero
  39. 2D2A0001 # LOADUI R10 1 ; Our toggle
  40. 2D2900ff # LOADUI R9 0xFF ; Byte mask
  41. 2D28000f # LOADUI R8 0x0F ; nybble mask
  42. # ;; Prep TAPE_02
  43. 2D201101 # LOADUI R0 0x1101
  44. 42100001 # FOPEN_WRITE
  45. 2D0F @second_pass # CALLI R15 @second_pass
  46. # ;; Close up as we are done
  47. 2D201100 # LOADUI R0 0x1100 ; Close TAPE_01
  48. 42100002 # FCLOSE
  49. 2D201101 # LOADUI R0 0x1101 ; Close TAPE_02
  50. 42100002 # FCLOSE
  51. FFFFFFFF # HALT
  52. # ;; First pass function
  53. # ;; Reads Tape_01 and creates our label table
  54. # ;; Will Overwrite R0 R10 R11
  55. # ;; Returns to Main function when done
  56. :first_pass
  57. 2D211100 # LOADUI R1 0x1100 ; Read from tape_01
  58. 42100100 # FGETC ; Read a Char
  59. # ;; Check for EOF
  60. A0100000 # CMPSKIPI.GE R0 0
  61. 0D01001F # RET R15
  62. # ;; Check for and deal with label (:)
  63. A030003a # CMPSKIPI.NE R0 58
  64. 3C00 @storeLabel # JUMP @storeLabel
  65. # ;; Check for and deal with pointers to labels
  66. # ;; Starting with (@)
  67. A0300040 # CMPSKIPI.NE R0 64
  68. 3C00 @ThrowAwayPointer # JUMP @ThrowAwayPointer
  69. # ;; Then dealing with ($)
  70. A0300024 # CMPSKIPI.NE R0 36
  71. 3C00 @ThrowAwayPointer # JUMP @ThrowAwayPointer
  72. # ;; Now check for absolute addresses (&)
  73. A0300026 # CMPSKIPI.NE R0 38
  74. 3C00 @ThrowAwayAddress # JUMP @ThrowAwayAddress
  75. # ;; Otherwise attempt to process
  76. 2D0F @hex # CALLI R15 @hex ; Convert it
  77. A0100000 # CMPSKIPI.GE R0 0 ; Don't record, nonhex values
  78. 3C00 @first_pass # JUMP @first_pass ; Move onto Next char
  79. # ;; Determine if we got a full byte
  80. 2C9A @first_pass_0 # JUMP.Z R10 @first_pass_0 ; Jump if toggled
  81. # ;; Deal with case of first half of byte
  82. 0D00002A # FALSE R10 ; Flip the toggle
  83. 3C00 @first_pass # JUMP @first_pass
  84. :first_pass_0
  85. # ;; Deal with case of second half of byte
  86. 0D00003A # TRUE R10 ; Flip the toggle
  87. 0FBB0001 # ADDUI R11 R11 1 ; increment PC now that that we have a full byte
  88. 3C00 @first_pass # JUMP @first_pass
  89. # ;; Second pass function
  90. # ;; Reads from Tape_01 and uses the values in the table
  91. # ;; To write desired contents onto Tape_02
  92. # ;; Will Overwrite R0 R10 R11
  93. # ;; Returns to Main function when done
  94. :second_pass
  95. 2D211100 # LOADUI R1 0x1100 ; Read from tape_01
  96. 42100100 # FGETC ; Read a Char
  97. # ;; Check for EOF
  98. A0100000 # CMPSKIPI.GE R0 0
  99. 0D01001F # RET R15
  100. # ;; Check for and deal with label
  101. A030003a # CMPSKIPI.NE R0 58
  102. 3C00 @ThrowAwayLabel # JUMP @ThrowAwayLabel
  103. # ;; Check for and deal with Pointers to labels
  104. A0300040 # CMPSKIPI.NE R0 64 ; @ for relative
  105. 3C00 @StoreRelativePointer # JUMP @StoreRelativePointer
  106. A0300024 # CMPSKIPI.NE R0 36 ; $ for absolute
  107. 3C00 @StoreAbsolutePointer # JUMP @StoreAbsolutePointer
  108. A0300026 # CMPSKIPI.NE R0 38 ; & for address
  109. 3C00 @StoreAbsoluteAddress # JUMP @StoreAbsoluteAddress
  110. # ;; Process everything else
  111. 2D0F @hex # CALLI R15 @hex ; Attempt to Convert it
  112. A0100000 # CMPSKIPI.GE R0 0 ; Don't record, nonhex values
  113. 3C00 @second_pass # JUMP @second_pass ; Move onto Next char
  114. # ;; Determine if we got a full byte
  115. 2C9A @second_pass_0 # JUMP.Z R10 @second_pass_0 ; Jump if toggled
  116. # ;; Deal with case of first half of byte
  117. 05020C08 # AND R12 R0 R8 ; Store our first nibble
  118. 0D00002A # FALSE R10 ; Flip the toggle
  119. 3C00 @second_pass # JUMP @second_pass
  120. :second_pass_0
  121. # ;; Deal with case of second half of byte
  122. 2D5C0004 # SL0I R12 4 ; Shift our first nybble
  123. 05020008 # AND R0 R0 R8 ; Mask out top
  124. 0500000C # ADD R0 R0 R12 ; Combine nybbles
  125. 0D00003A # TRUE R10 ; Flip the toggle
  126. 2D211101 # LOADUI R1 0x1101 ; Write the combined byte
  127. 42100200 # FPUTC ; To TAPE_02
  128. 0FBB0001 # ADDUI R11 R11 1 ; increment PC now that that we have a full byte
  129. 3C00 @second_pass # JUMP @second_pass
  130. # ;; Store Label function
  131. # ;; Writes out the token and the current PC value
  132. # ;; Its static variable for storing the next index to be used
  133. # ;; Will overwrite R0
  134. # ;; Returns to first pass when done
  135. :storeLabel
  136. 2E00 @current_index # LOADR R0 @current_index ; Get address of first open index
  137. A0300000 # CMPSKIPI.NE R0 0 ; If zero intialize from R13
  138. 0900040D # COPY R0 R13
  139. # ;; Store the PC of the label
  140. 23B00000 # STORE32 R11 R0 0
  141. # ;; Store the name of the Label
  142. 0F000004 # ADDUI R0 R0 4 ; Increment the offset of the index
  143. 2D0F @writeout_token # CALLI R15 @writeout_token
  144. # ;; Update our index
  145. 0F00003c # ADDUI R0 R0 60 ; Hopefully our tokens are less than 60 bytes long
  146. 2F00 @current_index # STORER R0 @current_index
  147. # ;; And be done
  148. 3C00 @first_pass # JUMP @first_pass
  149. # ;; Where we are storing the location of the next free table entry
  150. :current_index
  151. 00000000 # NOP
  152. # ;; StoreRelativepointer function
  153. # ;; Deals with the special case of relative pointers
  154. # ;; Clears Temp
  155. # ;; Stores string in Temp
  156. # ;; Finds match in Table
  157. # ;; Writes out the offset
  158. # ;; Modifies R0 R11
  159. # ;; Jumps back into Pass2
  160. :StoreRelativePointer
  161. # ;; Correct the PC to reflect the size of the pointer
  162. 0FBB0002 # ADDUI R11 R11 2 ; Exactly 2 bytes
  163. 2D20 $Temp # LOADUI R0 $Temp ; Set where we want to shove our string
  164. 2D0F @Clear_string # CALLI R15 @Clear_string ; Clear it
  165. 2D0F @writeout_token # CALLI R15 @writeout_token ; Write it
  166. 2D0F @Match_string # CALLI R15 @Match_string ; Find the Match
  167. 1800fffc # LOAD32 R0 R0 -4 ; Get the value we care about
  168. 0500200B # SUB R0 R0 R11 ; Determine the difference
  169. 0F000004 # ADDUI R0 R0 4 ; Adjust for relative positioning
  170. 2D0F @ProcessImmediate # CALLI R15 @ProcessImmediate ; Write out the value
  171. 3C00 @second_pass # JUMP @second_pass
  172. # ;; StoreAbsolutepointer function
  173. # ;; Deals with the special case of absolute pointers
  174. # ;; Clears Temp
  175. # ;; Stores string in Temp
  176. # ;; Finds match in Table
  177. # ;; Writes out the absolute address of match
  178. # ;; Modifies R0 R11
  179. # ;; Jumps back into Pass2
  180. :StoreAbsolutePointer
  181. # ;; Correct the PC to reflect the size of the pointer
  182. 0FBB0002 # ADDUI R11 R11 2 ; Exactly 2 bytes
  183. 2D20 $Temp # LOADUI R0 $Temp ; Set where we want to shove our string
  184. 2D0F @Clear_string # CALLI R15 @Clear_string ; Clear it
  185. 2D0F @writeout_token # CALLI R15 @writeout_token ; Write it
  186. 2D0F @Match_string # CALLI R15 @Match_string ; Find the Match
  187. 1800fffc # LOAD32 R0 R0 -4 ; Get the value we care about
  188. 2D0F @ProcessImmediate # CALLI R15 @ProcessImmediate ; Write out the value
  189. 3C00 @second_pass # JUMP @second_pass
  190. # ;; StoreAbsoluteAddress function
  191. # ;; Deal with the special case of absolute Addresses
  192. # ;; Clear Temp
  193. # ;; Stores string in Temp
  194. # ;; Finds match in Table
  195. # ;; Writes out the full absolute address [32 bit machine]
  196. # ;; Modifies R0 R11
  197. # ;; Jumpbacs back into Pass2
  198. :StoreAbsoluteAddress
  199. # ;; COrrect the PC to reflect the size of the address
  200. 0FBB0004 # ADDUI R11 R11 4 ; 4 Bytes on 32bit machines
  201. 2D20 $Temp # LOADUI R0 $Temp ; Set where we ant to shove our string
  202. 2D0F @Clear_string # CALLI R15 @Clear_string ; Clear it
  203. 2D0F @writeout_token # CALLI R15 @writeout_token ; Write it
  204. 2D0F @Match_string # CALLI R15 @Match_string ; Find the Match
  205. 090200EF # PUSHR R14 R15 ; Get a temp storage place
  206. 18E0fffc # LOAD32 R14 R0 -4 ; Get the value we care about
  207. 0900040E # COPY R0 R14 ; We need to print the top 2 bytes first
  208. 2D400010 # SARI R0 16 ; Drop bottom 16 bits
  209. 2D0F @ProcessImmediate # CALLI R15 @ProcessImmediate ; Write out top 2 bytes
  210. 2D20ffff # LOADUI R0 0xFFFF ; Provide mask to keep bottom 2 bytes
  211. 0502000E # AND R0 R0 R14 ; Drop top 16 bits
  212. 090280EF # POPR R14 R15 ; Restore R14
  213. 2D0F @ProcessImmediate # CALLI R15 @ProcessImmediate ; Write out bottom 2 bytes
  214. 3C00 @second_pass # JUMP @second_pass
  215. # ;; Writeout Token Function
  216. # ;; Writes the Token [minus first char] to the address
  217. # ;; It recieves in R0 until it reaches a delimiter
  218. # ;; All register values are preserved
  219. # ;; Returns to whatever called it
  220. :writeout_token
  221. # ;; Preserve registers
  222. 0902000F # PUSHR R0 R15
  223. 0902001F # PUSHR R1 R15
  224. 0902002F # PUSHR R2 R15
  225. # ;; Initialize
  226. 09000520 # MOVE R2 R0 ; Set R2 as our index
  227. 2D211100 # LOADUI R1 0x1100 ; Read from tape_01
  228. # ;; Our core loop
  229. :writeout_token_0
  230. 42100100 # FGETC ; Get another byte
  231. # ;; Deal with termination cases
  232. A0300020 # CMPSKIPI.NE R0 32 ; Finished if space
  233. 3C00 @writeout_token_done # JUMP @writeout_token_done
  234. A0300009 # CMPSKIPI.NE R0 9 ; Finished if tab
  235. 3C00 @writeout_token_done # JUMP @writeout_token_done
  236. A030000a # CMPSKIPI.NE R0 10 ; Finished if newline
  237. 3C00 @writeout_token_done # JUMP @writeout_token_done
  238. # ;; Deal with valid input
  239. 21020000 # STORE8 R0 R2 0 ; Write out the byte
  240. 0F220001 # ADDUI R2 R2 1 ; Increment
  241. 3C00 @writeout_token_0 # JUMP @writeout_token_0 ; Keep looping
  242. # ;; Clean up now that we are done
  243. :writeout_token_done
  244. # ;; Restore registers
  245. 0902802F # POPR R2 R15
  246. 0902801F # POPR R1 R15
  247. 0902800F # POPR R0 R15
  248. # ;; And be done
  249. 0D01001F # RET R15
  250. # ;; Clear string function
  251. # ;; Clears string pointed at by the value of R0
  252. # ;; Until a null character is reached
  253. # ;; Doesn't alter any registers
  254. # ;; Returns to the function that calls it
  255. :Clear_string
  256. # ;; Preserve registers
  257. 0902000F # PUSHR R0 R15
  258. 0902001F # PUSHR R1 R15
  259. 0902002F # PUSHR R2 R15
  260. 0902003F # PUSHR R3 R15
  261. # ;; Setup registers
  262. 09000510 # MOVE R1 R0
  263. 2D220000 # LOADUI R2 0
  264. 2D230000 # LOADUI R3 0
  265. :clear_byte
  266. 0503A012 # LOADXU8 R0 R1 R2 ; Get the byte
  267. 05049312 # STOREX8 R3 R1 R2 ; Overwrite with a Zero
  268. 0F220001 # ADDUI R2 R2 1 ; Prep for next loop
  269. 2CA0 @clear_byte # JUMP.NZ R0 @clear_byte ; Stop if byte is NULL
  270. # ;; Done
  271. # ;; Restore registers
  272. 0902803F # POPR R3 R15
  273. 0902802F # POPR R2 R15
  274. 0902801F # POPR R1 R15
  275. 0902800F # POPR R0 R15
  276. 0D01001F # RET R15
  277. # ;; Match string function
  278. # ;; Walks down table until match is found
  279. # ;; Then returns address of matching string in R0
  280. # ;; Returns to whatever called it
  281. :Match_string
  282. # ;; Preserve registers
  283. 0902001F # PUSHR R1 R15
  284. 0902002F # PUSHR R2 R15
  285. # ;; Initialize for Loop
  286. 2D21 $Temp # LOADUI R1 $Temp ; We always compare against Temp
  287. 2D22 $table # LOADUI R2 $table ; Begin at start of table
  288. 0F220004 # ADDUI R2 R2 4 ; Where the string is located
  289. # ;; Loop until we find a match
  290. :Match_string_0
  291. 09000402 # COPY R0 R2 ; Set R0 to our current string
  292. 2D0F @strcmp # CALLI R15 @strcmp
  293. 2C50 @Match_string_1 # JUMP.E R0 @Match_string_1 ; It is a match!
  294. # ;; Prepare for next loop
  295. 2D21 $Temp # LOADUI R1 $Temp ; That function clears R1
  296. 0F220040 # ADDUI R2 R2 64 ; Each Index is 64 bytes
  297. 3C00 @Match_string_0 # JUMP @Match_string_0 ; Keep looping
  298. :Match_string_1
  299. # ;; Store the correct answer
  300. 09000502 # MOVE R0 R2
  301. # ;; Restore registers
  302. 0902802F # POPR R2 R15
  303. 0902801F # POPR R1 R15
  304. 0D01001F # RET R15
  305. # ;; Our simple string compare function
  306. # ;; Recieves two pointers in R0 and R1
  307. # ;; Returns the difference between the strings in R0
  308. # ;; Clears R1
  309. # ;; Returns to whatever called it
  310. :strcmp
  311. # ;; Preserve registers
  312. 0902002F # PUSHR R2 R15
  313. 0902003F # PUSHR R3 R15
  314. 0902004F # PUSHR R4 R15
  315. # ;; Setup registers
  316. 09000520 # MOVE R2 R0
  317. 09000531 # MOVE R3 R1
  318. 2D240000 # LOADUI R4 0
  319. :cmpbyte
  320. 0503A024 # LOADXU8 R0 R2 R4 ; Get a byte of our first string
  321. 0503A134 # LOADXU8 R1 R3 R4 ; Get a byte of our second string
  322. 0F440001 # ADDUI R4 R4 1 ; Prep for next loop
  323. 05004101 # CMP R1 R0 R1 ; Compare the bytes
  324. A0200000 # CMPSKIPI.E R0 0 ; Stop if byte is NULL
  325. 2C51 @cmpbyte # JUMP.E R1 @cmpbyte ; Loop if bytes are equal
  326. # ;; Done
  327. 09000501 # MOVE R0 R1 ; Prepare for return
  328. # ;; Restore registers
  329. 0902804F # POPR R4 R15
  330. 0902803F # POPR R3 R15
  331. 0902802F # POPR R2 R15
  332. 0D01001F # RET R15
  333. # ;; Processimmediate Function
  334. # ;; Recieves an integer value in R0
  335. # ;; Writes out the values to Tape_02
  336. # ;; Doesn't modify registers
  337. # ;; Returns to whatever called it
  338. :ProcessImmediate
  339. # ;; Preserve registers
  340. 0902000F # PUSHR R0 R15
  341. 0902001F # PUSHR R1 R15
  342. 0902002F # PUSHR R2 R15
  343. # ;; Break up Immediate
  344. 05020209 # AND R2 R0 R9 ; Put lower byte in R2
  345. 2D400008 # SARI R0 8 ; Drop Bottom byte from R0
  346. 05020009 # AND R0 R0 R9 ; Maskout everything outside of top byte
  347. # ;; Write out Top Byte
  348. 2D211101 # LOADUI R1 0x1101 ; Write the byte
  349. 42100200 # FPUTC ; To TAPE_02
  350. # ;; Write out bottom Byte
  351. 09000502 # MOVE R0 R2 ; Put Lower byte in R0
  352. 2D211101 # LOADUI R1 0x1101 ; Write the byte
  353. 42100200 # FPUTC ; To TAPE_02
  354. # ;; Restore registers
  355. 0902802F # POPR R2 R15
  356. 0902801F # POPR R1 R15
  357. 0902800F # POPR R0 R15
  358. # ;; Be Done
  359. 0D01001F # RET R15
  360. # ;; ThrowAwaypointer function
  361. # ;; Handle the special case of a generic problem
  362. # ;; for Pass1, Will update R11 and modify R0
  363. # ;; Will return to the start of first_pass
  364. # ;; Never call this function, only jump to it
  365. :ThrowAwayPointer
  366. 0FBB0002 # ADDUI R11 R11 2 ; Pointers always take up 2 bytes
  367. 2D0F @throwAwayToken # CALLI R15 @throwAwayToken ; Get rid of rest of token
  368. 3C00 @first_pass # JUMP @first_pass ; Then return to the proper place
  369. # ;; ThrowAwayAddress function
  370. # ;; Handle the case of a 32bit absolute address storage
  371. # ;; for Pass1, Will update R11 and modify R0
  372. # ;; Will return to the start of first_pass
  373. # ;; Never call this function, conly jump to it
  374. :ThrowAwayAddress
  375. 0FBB0004 # ADDUI R11 R11 4 ; Addresses on 32bit systems take up 4 bytes
  376. 2D0F @throwAwayToken # CALLI R15 @throwAwayToken ; Get rid of rest of token
  377. 3C00 @first_pass # JUMP @first_pass ; Then return to the proper place
  378. # ;; ThrowAwaylabel function
  379. # ;; Handle the special case of a generic problem
  380. # ;; for Pass2, Will update R11 and modify R0
  381. # ;; Will return to the start of second_pass
  382. # ;; Never call this function, only jump to it
  383. :ThrowAwayLabel
  384. 2D0F @throwAwayToken # CALLI R15 @throwAwayToken ; Get rid of rest of token
  385. 3C00 @second_pass # JUMP @second_pass
  386. # ;; Throw away token function
  387. # ;; Deals with the general case of not wanting
  388. # ;; The rest of the characters in a token
  389. # ;; This Will alter the values of R0 R1
  390. # ;; Returns back to whatever called it
  391. :throwAwayToken
  392. 2D211100 # LOADUI R1 0x1100 ; Read from tape_01
  393. 42100100 # FGETC ; Read a Char
  394. # ;; Stop looping if space
  395. A0300020 # CMPSKIPI.NE R0 32
  396. 0D01001F # RET R15
  397. # ;; Stop looping if tab
  398. A0300009 # CMPSKIPI.NE R0 9
  399. 0D01001F # RET R15
  400. # ;; Stop looping if newline
  401. A030000a # CMPSKIPI.NE R0 10
  402. 0D01001F # RET R15
  403. # ;; Otherwise keep looping
  404. 3C00 @throwAwayToken # JUMP @throwAwayToken
  405. # ;; Hex function
  406. # ;; This function is serving three purposes:
  407. # ;; Identifying hex characters
  408. # ;; Purging line comments
  409. # ;; Returning the converted value of a hex character
  410. # ;; This function will alter the values of R0 R14
  411. # ;; Returns back to whatever called it
  412. :hex
  413. # ;; Deal with line comments starting with #
  414. 1FE00023 # CMPUI R14 R0 35
  415. 2C5E @ascii_comment # JUMP.E R14 @ascii_comment
  416. # ;; Deal with line comments starting with ;
  417. 1FE0003b # CMPUI R14 R0 59
  418. 2C5E @ascii_comment # JUMP.E R14 @ascii_comment
  419. # ;; Deal with all ascii less than '0'
  420. 1FE00030 # CMPUI R14 R0 48
  421. 2C8E @ascii_other # JUMP.L R14 @ascii_other
  422. # ;; Deal with '0'-'9'
  423. 1FE00039 # CMPUI R14 R0 57
  424. 2C7E @ascii_num # JUMP.LE R14 @ascii_num
  425. # ;; Deal with all ascii less than 'A'
  426. 1FE00041 # CMPUI R14 R0 65
  427. 2C8E @ascii_other # JUMP.L R14 @ascii_other
  428. # ;; Deal with 'A'-'F'
  429. 1FE00046 # CMPUI R14 R0 70
  430. 2C7E @ascii_high # JUMP.LE R14 @ascii_high
  431. # ;; Deal with all ascii less than 'a'
  432. 1FE00061 # CMPUI R14 R0 97
  433. 2C8E @ascii_other # JUMP.L R14 @ascii_other
  434. # ;; Deal with 'a'-'f'
  435. 1FE00066 # CMPUI R14 R0 102
  436. 2C7E @ascii_low # JUMP.LE R14 @ascii_low
  437. # ;; Ignore the rest
  438. 3C00 @ascii_other # JUMP @ascii_other
  439. :ascii_num
  440. 11000030 # SUBUI R0 R0 48
  441. 0D01001F # RET R15
  442. :ascii_low
  443. 11000057 # SUBUI R0 R0 87
  444. 0D01001F # RET R15
  445. :ascii_high
  446. 11000037 # SUBUI R0 R0 55
  447. 0D01001F # RET R15
  448. :ascii_other
  449. 0D000030 # TRUE R0
  450. 0D01001F # RET R15
  451. :ascii_comment
  452. 2D211100 # LOADUI R1 0x1100 ; Read from TAPE_01
  453. 42100100 # FGETC ; Read another char
  454. 1FE0000a # CMPUI R14 R0 10 ; Stop at the end of line
  455. 2C6E @ascii_comment # JUMP.NE R14 @ascii_comment ; Otherwise keep looping
  456. 3C00 @ascii_other # JUMP @ascii_other
  457. # ;; Where we are storing our Temp
  458. :Temp
  459. 00000000 # NOP
  460. 00000000 # NOP
  461. 00000000 # NOP
  462. 00000000 # NOP
  463. 00000000 # NOP
  464. 00000000 # NOP
  465. 00000000 # NOP
  466. 00000000 # NOP
  467. 00000000 # NOP
  468. 00000000 # NOP
  469. 00000000 # NOP
  470. 00000000 # NOP
  471. 00000000 # NOP
  472. 00000000 # NOP
  473. 00000000 # NOP
  474. 00000000 # NOP
  475. # ;; Where we will putting our Table
  476. :table