more.hex0 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # :start
  17. 2D22000a # LOADUI R2 10 ; We will be using R2 for our counter
  18. # ;; Prep TAPE_01
  19. 2D201100 # LOADUI R0 0x1100
  20. 42100000 # FOPEN_READ
  21. # :main
  22. # ;; Read a byte
  23. 2D211100 # LOADUI R1 0x1100
  24. 42100100 # FGETC
  25. # ;; Check for EOF
  26. A0100000 # CMPSKIPI.GE R0 0
  27. 3C000028 # JUMP @main_1
  28. # ;; Write the Byte
  29. 0D000021 # FALSE R1
  30. 42100200 # FPUTC
  31. # ;; Check for LF
  32. A030000a # CMPSKIPI.NE R0 10 ; Skip if not line feed
  33. 10220001 # SUBI R2 R2 1 ; Decrement on line feed
  34. # ;; Loop if not Zero
  35. A0220000 # CMPSKIPI.E R2 0 ; Skip if counter is zero
  36. 3C00ffdc # JUMP @main
  37. # ;; Otherwise provide main loop functionality
  38. 42100100 # FGETC ; Wait for key press
  39. 2D22000a # LOADUI R2 10 ; Reset counter
  40. 3C00ffd0 # JUMP @main ; And loop
  41. # :main_1
  42. # ;; Close up as we are done
  43. 2D201100 # LOADUI R0 0x1100 ; Close TAPE_01
  44. 42100002 # FCLOSE
  45. FFFFFFFF # HALT