2014-02-10 20:20:52 +04:00
|
|
|
#include "core-isa.h"
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
.macro test_suite name
|
|
|
|
.data
|
|
|
|
status: .word result
|
2020-07-01 04:04:49 +03:00
|
|
|
result: .space 1024
|
2011-09-06 03:55:57 +04:00
|
|
|
.text
|
|
|
|
.global main
|
|
|
|
.align 4
|
|
|
|
main:
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro reset_ps
|
|
|
|
movi a2, 0x4000f
|
|
|
|
wsr a2, ps
|
|
|
|
isync
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro test_suite_end
|
|
|
|
reset_ps
|
|
|
|
movi a0, status
|
|
|
|
l32i a2, a0, 0
|
|
|
|
movi a0, result
|
|
|
|
sub a2, a2, a0
|
|
|
|
movi a3, 0
|
2019-02-18 17:16:08 +03:00
|
|
|
beqz a2, 2f
|
2011-09-06 03:55:57 +04:00
|
|
|
1:
|
2020-07-01 04:04:49 +03:00
|
|
|
l32i a1, a0, 0
|
2019-02-18 17:16:08 +03:00
|
|
|
or a3, a3, a1
|
2020-07-01 04:04:49 +03:00
|
|
|
addi a0, a0, 4
|
2019-02-18 17:16:08 +03:00
|
|
|
addi a2, a2, -1
|
|
|
|
bnez a2, 1b
|
|
|
|
2:
|
2011-09-06 03:55:57 +04:00
|
|
|
exit
|
|
|
|
.endm
|
|
|
|
|
2012-03-16 01:24:57 +04:00
|
|
|
.macro print text
|
|
|
|
.data
|
|
|
|
97: .ascii "\text\n"
|
|
|
|
98:
|
|
|
|
.align 4
|
|
|
|
.text
|
|
|
|
movi a2, 4
|
|
|
|
movi a3, 2
|
|
|
|
movi a4, 97b
|
|
|
|
movi a5, 98b
|
|
|
|
sub a5, a5, a4
|
|
|
|
simcall
|
|
|
|
.endm
|
|
|
|
|
2014-02-10 12:26:45 +04:00
|
|
|
.macro test_init
|
|
|
|
.endm
|
|
|
|
|
2011-09-06 03:55:57 +04:00
|
|
|
.macro test name
|
2019-02-18 12:42:15 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
print test_\name
|
|
|
|
#endif
|
2014-02-10 12:26:45 +04:00
|
|
|
test_init
|
2012-03-16 01:24:57 +04:00
|
|
|
test_\name:
|
|
|
|
.global test_\name
|
2011-09-06 03:55:57 +04:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro test_end
|
|
|
|
99:
|
|
|
|
reset_ps
|
|
|
|
movi a2, status
|
|
|
|
l32i a3, a2, 0
|
2020-07-01 04:04:49 +03:00
|
|
|
addi a3, a3, 4
|
2011-09-06 03:55:57 +04:00
|
|
|
s32i a3, a2, 0
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro exit
|
|
|
|
movi a2, 1
|
|
|
|
simcall
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro test_fail
|
|
|
|
movi a2, status
|
|
|
|
l32i a2, a2, 0
|
|
|
|
movi a3, 1
|
2020-07-01 04:04:49 +03:00
|
|
|
s32i a3, a2, 0
|
2019-02-18 12:42:15 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
print failed
|
|
|
|
#endif
|
2011-09-06 03:55:57 +04:00
|
|
|
j 99f
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro assert cond, arg1, arg2
|
|
|
|
b\cond \arg1, \arg2, 90f
|
|
|
|
test_fail
|
|
|
|
90:
|
|
|
|
nop
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro set_vector vector, addr
|
|
|
|
movi a2, handler_\vector
|
|
|
|
movi a3, \addr
|
|
|
|
s32i a3, a2, 0
|
|
|
|
.endm
|
2019-02-18 17:24:38 +03:00
|
|
|
|
2012-09-06 04:23:44 +04:00
|
|
|
.macro dump r
|
|
|
|
#ifdef DEBUG
|
|
|
|
.data
|
|
|
|
.align 4
|
|
|
|
1: .word 0
|
|
|
|
.text
|
|
|
|
movi a4, 1b
|
|
|
|
s32i a2, a4, 0
|
|
|
|
movi a2, 4
|
|
|
|
movi a3, 1
|
|
|
|
movi a5, 4
|
|
|
|
simcall
|
|
|
|
movi a4, 1b
|
|
|
|
l32i a2, a4, 0
|
|
|
|
#endif
|
|
|
|
.endm
|
|
|
|
|
2019-02-18 17:24:38 +03:00
|
|
|
#define glue(a, b) _glue(a, b)
|
|
|
|
#define _glue(a, b) a ## b
|
2019-02-18 17:50:10 +03:00
|
|
|
|
|
|
|
#define glue3(a, b, c) _glue3(a, b, c)
|
|
|
|
#define _glue3(a, b, c) a ## b ## c
|