hello.M1 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ## Copyright (C) 2017 Jeremiah Orians
  2. ## This file is part of mescc-tools.
  3. ##
  4. ## mescc-tools 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. ## mescc-tools 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 mescc-tools. 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. :_start
  34. :main
  35. ^~print BL_ALWAYS
  36. !string1 R1 '0' ADDI_PC_ALWAYS
  37. !0 R0 '0' LOADB_FROM_R1_ALWAYS
  38. !1 R0 R0 SUBI_ALWAYS
  39. !0 R0 '0' STOREB_TO_R1_ALWAYS
  40. !0 R0 '0' CMPI_ALWAYS
  41. ^~main BNE
  42. ;; Exit returning success
  43. !0 R0 '0' LOADI_ALWAYS
  44. !1 R7 '0' LOADI_ALWAYS
  45. SYSCALL_ALWAYS
  46. <
  47. :print
  48. ;; Print our char
  49. !1 R0 '0' LOADI_ALWAYS
  50. !string1 R1 '0' ADDI_PC_ALWAYS
  51. !1 R2 '0' LOADI_ALWAYS
  52. !4 R7 '0' LOADI_ALWAYS
  53. SYSCALL_ALWAYS
  54. '0' R14 PC '0' MOVE_ALWAYS
  55. :ELF_data
  56. <10
  57. <
  58. :string1
  59. 'FF00'
  60. <