1.macro test_suite name 2.data 3status: .word result 4result: .space 20 5.text 6.global main 7.align 4 8main: 9.endm 10 11.macro reset_ps 12 movi a2, 0x4000f 13 wsr a2, ps 14 isync 15.endm 16 17.macro test_suite_end 18 reset_ps 19 movi a0, status 20 l32i a2, a0, 0 21 movi a0, result 22 sub a2, a2, a0 23 movi a3, 0 24 loopnez a2, 1f 25 l8ui a2, a0, 0 26 or a3, a3, a2 27 addi a0, a0, 1 281: 29 exit 30.endm 31 32.macro print text 33.data 3497: .ascii "\text\n" 3598: 36 .align 4 37.text 38 movi a2, 4 39 movi a3, 2 40 movi a4, 97b 41 movi a5, 98b 42 sub a5, a5, a4 43 simcall 44.endm 45 46.macro test name 47 //print test_\name 48test_\name: 49.global test_\name 50.endm 51 52.macro test_end 5399: 54 reset_ps 55 movi a2, status 56 l32i a3, a2, 0 57 addi a3, a3, 1 58 s32i a3, a2, 0 59.endm 60 61.macro exit 62 movi a2, 1 63 simcall 64.endm 65 66.macro test_fail 67 movi a2, status 68 l32i a2, a2, 0 69 movi a3, 1 70 s8i a3, a2, 0 71 j 99f 72.endm 73 74.macro assert cond, arg1, arg2 75 b\cond \arg1, \arg2, 90f 76 test_fail 7790: 78 nop 79.endm 80 81.macro set_vector vector, addr 82 movi a2, handler_\vector 83 movi a3, \addr 84 s32i a3, a2, 0 85.endm 86