testutils.inc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # r0-r3 are used as tmps, consider them call clobbered by these macros.
  2. # This uses the angel rom monitor calls.
  3. # ??? How do we use the \@ facility of .macros ???
  4. # @ is the comment char!
  5. .macro mvi_h_gr reg, val
  6. ldr \reg,[pc]
  7. b . + 8
  8. .word \val
  9. .endm
  10. .macro mvaddr_h_gr reg, addr
  11. ldr \reg,[pc]
  12. b . + 8
  13. .word \addr
  14. .endm
  15. .macro start
  16. .data
  17. failmsg:
  18. .asciz "fail\n"
  19. passmsg:
  20. .asciz "pass\n"
  21. .text
  22. do_pass:
  23. ldr r1, passmsg_addr
  24. mov r0, #4
  25. swi #0x123456
  26. exit 0
  27. passmsg_addr:
  28. .word passmsg
  29. do_fail:
  30. ldr r1, failmsg_addr
  31. mov r0, #4
  32. swi #0x123456
  33. exit 1
  34. failmsg_addr:
  35. .word failmsg
  36. .global _start
  37. _start:
  38. .endm
  39. # *** Other macros know pass/fail are 4 bytes in size! Yuck.
  40. .macro pass
  41. b do_pass
  42. .endm
  43. .macro fail
  44. b do_fail
  45. .endm
  46. .macro exit rc
  47. # ??? This works with the ARMulator but maybe not others.
  48. #mov r0, #\rc
  49. #swi #1
  50. # This seems to be portable (though it ignores rc).
  51. mov r0,#0x18
  52. mvi_h_gr r1, 0x20026
  53. swi #0x123456
  54. # If that returns, punt with a sigill.
  55. stc 0,cr0,[r0]
  56. .endm
  57. # Other macros know this only clobbers r0.
  58. # WARNING: It also clobbers the condition codes (FIXME).
  59. .macro test_h_gr reg, val
  60. mvaddr_h_gr r0, \val
  61. cmp \reg, r0
  62. beq . + 8
  63. fail
  64. .endm
  65. .macro mvi_h_cnvz c, n, v, z
  66. mov r0, #0
  67. .if \c
  68. orr r0, r0, #0x20000000
  69. .endif
  70. .if \n
  71. orr r0, r0, #0x80000000
  72. .endif
  73. .if \v
  74. orr r0, r0, #0x10000000
  75. .endif
  76. .if \z
  77. orr r0, r0, #0x40000000
  78. .endif
  79. mrs r1, cpsr
  80. bic r1, r1, #0xf0000000
  81. orr r1, r1, r0
  82. msr cpsr, r1
  83. # ??? nops needed
  84. .endm
  85. # ??? Preserve condition codes?
  86. .macro test_h_cnvz c, n, v, z
  87. mov r0, #0
  88. .if \c
  89. orr r0, r0, #0x20000000
  90. .endif
  91. .if \n
  92. orr r0, r0, #0x80000000
  93. .endif
  94. .if \v
  95. orr r0, r0, #0x10000000
  96. .endif
  97. .if \z
  98. orr r0, r0, #0x40000000
  99. .endif
  100. mrs r1, cpsr
  101. and r1, r1, #0xf0000000
  102. cmp r0, r1
  103. beq . + 8
  104. fail
  105. .endm