hello.M1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ## Copyright (C) 2017 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. DEFINE SYSCALL_ALWAYS 000000EF
  17. DEFINE LOADI_ALWAYS A0E3
  18. DEFINE ADDI_PC_ALWAYS 8FE2
  19. DEFINE SUBI_ALWAYS 40E2
  20. DEFINE MOVE_ALWAYS A0E1
  21. DEFINE CMPI_ALWAYS 50E3
  22. DEFINE BNE 1A
  23. DEFINE BL_ALWAYS EB
  24. DEFINE LOADB_FROM_R1_ALWAYS D1E5
  25. DEFINE STOREB_TO_R1_ALWAYS C1E5
  26. DEFINE R0 0
  27. DEFINE R1 1
  28. DEFINE R2 2
  29. DEFINE R3 3
  30. DEFINE R7 7
  31. DEFINE R14 E
  32. DEFINE PC F
  33. :main
  34. ^~print BL_ALWAYS
  35. !string1 R1 '0' ADDI_PC_ALWAYS
  36. !0 R0 '0' LOADB_FROM_R1_ALWAYS
  37. !1 R0 R0 SUBI_ALWAYS
  38. !0 R0 '0' STOREB_TO_R1_ALWAYS
  39. !0 R0 '0' CMPI_ALWAYS
  40. ^~main BNE
  41. ;; Exit returning success
  42. !0 R0 '0' LOADI_ALWAYS
  43. !1 R7 '0' LOADI_ALWAYS
  44. SYSCALL_ALWAYS
  45. <
  46. :print
  47. ;; Print our char
  48. !1 R0 '0' LOADI_ALWAYS
  49. !string1 R1 '0' ADDI_PC_ALWAYS
  50. !1 R2 '0' LOADI_ALWAYS
  51. !4 R7 '0' LOADI_ALWAYS
  52. SYSCALL_ALWAYS
  53. '0' R14 PC '0' MOVE_ALWAYS
  54. :ELF_data
  55. <10
  56. <
  57. :string1
  58. 'FF00'
  59. <