GNU Binutils with patches for OS216
Revisión | e2e9097bd21406f09fdf57fee0d99e6b45de61b6 (tree) |
---|---|
Tiempo | 2019-09-24 06:11:16 |
Autor | Dimitar Dimitrov <dimitar@dinu...> |
Commiter | Andrew Burgess |
Add testsuite for the PRU simulator port
sim/testsuite/ChangeLog:
* configure: Regenerate.
sim/testsuite/sim/pru/ChangeLog:
* add.s: New test.
* allinsn.exp: New file.
* dmem-zero-pass.s: New test.
* dmem-zero-trap.s: New test.
* dram.s: New test.
* jmp.s: New test.
* loop-imm.s: New test.
* loop-reg.s: New test.
* mul.s: New test.
* subreg.s: New test.
* testutils.inc: New file.
@@ -1,3 +1,7 @@ | ||
1 | +2019-09-23 Dimitar Dimitrov <dimitar@dinux.eu> | |
2 | + | |
3 | + * configure: Regenerate. | |
4 | + | |
1 | 5 | 2017-12-12 Stafford Horne <shorne@gmail.com> |
2 | 6 | Peter Gavin <pgavin@gmail.com> |
3 | 7 |
@@ -1946,6 +1946,9 @@ case "${target}" in | ||
1946 | 1946 | powerpc*-*-*) |
1947 | 1947 | sim_arch=ppc |
1948 | 1948 | ;; |
1949 | + pru*-*-*) | |
1950 | + sim_arch=pru | |
1951 | + ;; | |
1949 | 1952 | ft32-*-*) |
1950 | 1953 | sim_arch=ft32 |
1951 | 1954 | ;; |
@@ -0,0 +1,13 @@ | ||
1 | +2019-09-23 Dimitar Dimitrov <dimitar@dinux.eu> | |
2 | + | |
3 | + * add.s: New test. | |
4 | + * allinsn.exp: New file. | |
5 | + * dmem-zero-pass.s: New test. | |
6 | + * dmem-zero-trap.s: New test. | |
7 | + * dram.s: New test. | |
8 | + * jmp.s: New test. | |
9 | + * loop-imm.s: New test. | |
10 | + * loop-reg.s: New test. | |
11 | + * mul.s: New test. | |
12 | + * subreg.s: New test. | |
13 | + * testutils.inc: New file. |
@@ -0,0 +1,40 @@ | ||
1 | +# Check that basic add insn works. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + ldi r4, 10 | |
27 | + add r4, r4, 23 | |
28 | + qbne 2f, r4, 33 | |
29 | + | |
30 | + qblt 2f, r4, 33 | |
31 | + | |
32 | + qbgt 2f, r4, 33 | |
33 | + | |
34 | + jmp 1f | |
35 | + | |
36 | + fail | |
37 | + | |
38 | +1: | |
39 | + pass | |
40 | +2: fail |
@@ -0,0 +1,33 @@ | ||
1 | +# PRU simulator testsuite. | |
2 | + | |
3 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
4 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
5 | +# | |
6 | +# This file is part of the GNU simulators. | |
7 | +# | |
8 | +# This program is free software; you can redistribute it and/or modify | |
9 | +# it under the terms of the GNU General Public License as published by | |
10 | +# the Free Software Foundation; either version 3 of the License, or | |
11 | +# (at your option) any later version. | |
12 | +# | |
13 | +# This program is distributed in the hope that it will be useful, | |
14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | +# GNU General Public License for more details. | |
17 | +# | |
18 | +# You should have received a copy of the GNU General Public License | |
19 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | + | |
21 | +if [istarget pru-*] { | |
22 | + # all machines | |
23 | + set all_machs "pru" | |
24 | + | |
25 | + foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.s]] { | |
26 | + # If we're only testing specific files and this isn't one of them, | |
27 | + # skip it. | |
28 | + if ![runtest_file_p $runtests $src] { | |
29 | + continue | |
30 | + } | |
31 | + run_sim_test $src $all_machs | |
32 | + } | |
33 | +} |
@@ -0,0 +1,29 @@ | ||
1 | +# Check that DMEM zero address access works by default. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + ldi r1, 0 | |
27 | + lbbo &r2, r1, 0, 4 | |
28 | + | |
29 | + pass |
@@ -0,0 +1,32 @@ | ||
1 | +# Check that DMEM zero address access can be trapped. | |
2 | +# mach: pru | |
3 | +# sim: --error-null-deref | |
4 | +# xerror: | |
5 | +# output: core: 4 byte read to unmapped address 0x0 at *\n | |
6 | + | |
7 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
8 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
9 | +# | |
10 | +# This file is part of the GNU simulators. | |
11 | +# | |
12 | +# This program is free software; you can redistribute it and/or modify | |
13 | +# it under the terms of the GNU General Public License as published by | |
14 | +# the Free Software Foundation; either version 3 of the License, or | |
15 | +# (at your option) any later version. | |
16 | +# | |
17 | +# This program is distributed in the hope that it will be useful, | |
18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | +# GNU General Public License for more details. | |
21 | +# | |
22 | +# You should have received a copy of the GNU General Public License | |
23 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
24 | + | |
25 | +.include "testutils.inc" | |
26 | + | |
27 | + start | |
28 | + | |
29 | + ldi r1, 0 | |
30 | + lbbo &r2, r1, 0, 4 | |
31 | + | |
32 | + pass |
@@ -0,0 +1,72 @@ | ||
1 | +# Check that DRAM memory access works. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + fill r20, 16 | |
27 | + ldi r10, 0 | |
28 | + not r10, r10 | |
29 | + qbne F, r20, r10 | |
30 | + qbne F, r21, r10 | |
31 | + qbne F, r22, r10 | |
32 | + qbne F, r23, r10 | |
33 | + | |
34 | + zero r20, 16 | |
35 | + qbne F, r20, 0 | |
36 | + qbne F, r21, 0 | |
37 | + qbne F, r22, 0 | |
38 | + qbne F, r23, 0 | |
39 | + | |
40 | + ldi r0, testarray | |
41 | + lbbo &r20, r0, 0, 7 | |
42 | + qbne F, r20.b0, 0x01 | |
43 | + qbne F, r20.b1, 0x23 | |
44 | + qbne F, r20.b2, 0x45 | |
45 | + qbne F, r20.b3, 0x67 | |
46 | + qbne F, r21.b0, 0x89 | |
47 | + qbne F, r21.b1, 0xab | |
48 | + qbne F, r21.b2, 0xcd | |
49 | + qbne F, r21.b3, 0x00 ; Should not have been loaded! | |
50 | + qbne F, r22, 0 | |
51 | + qbne F, r23, 0 | |
52 | + | |
53 | + ldi r1, 0x11 | |
54 | + sbbo &r1, r0, 9, 1 | |
55 | + ldi r1, 0x11 | |
56 | + sbbo &r1, r0, 12, 4 | |
57 | + | |
58 | + lbbo &r20, r0, 0, 16 | |
59 | + qbne F, r21.b3, 0xef | |
60 | + qbne F, r22.b0, 0xff | |
61 | + qbne F, r22.b1, 0x11 | |
62 | + qbne F, r22.b2, 0xff | |
63 | + qbne F, r22.b3, 0xff | |
64 | + qbne F, r23, 0x11 | |
65 | + | |
66 | + pass | |
67 | +F: fail | |
68 | + | |
69 | + .data | |
70 | +testarray: | |
71 | + .byte 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef | |
72 | + .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
@@ -0,0 +1,40 @@ | ||
1 | +# Check that jump and branch insns work. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + ldi r10, 10 | |
27 | + call func1 | |
28 | + qbne F, r10, 11 | |
29 | + | |
30 | + ldi r0, %pmem(1f) | |
31 | + jmp r0 | |
32 | + fail | |
33 | +1: | |
34 | + pass | |
35 | +F: fail | |
36 | + | |
37 | + | |
38 | +func1: | |
39 | + add r10, r10, 1 | |
40 | + ret |
@@ -0,0 +1,43 @@ | ||
1 | +# Check that loop insn works. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + ldi r25, 0 | |
27 | + ldi r26, 0 | |
28 | + ldi r27, 0 | |
29 | + | |
30 | + add r27, r27, 1 | |
31 | + loop 1f, 10 | |
32 | + add r25, r25, 1 | |
33 | + add r26, r26, 2 | |
34 | +1: | |
35 | + add r27, r27, 1 | |
36 | + | |
37 | + qbne F, r25, 10 | |
38 | + qbne F, r26, 20 | |
39 | + qbne F, r27, 2 | |
40 | + | |
41 | + pass | |
42 | + | |
43 | +F: fail |
@@ -0,0 +1,44 @@ | ||
1 | +# Check that loop insn works. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + ldi r25, 0 | |
27 | + ldi r26, 0 | |
28 | + ldi r27, 0 | |
29 | + ldi r28, 10 | |
30 | + | |
31 | + add r27, r27, 1 | |
32 | + loop 1f, r28 | |
33 | + add r25, r25, 1 | |
34 | + add r26, r26, 2 | |
35 | +1: | |
36 | + add r27, r27, 1 | |
37 | + | |
38 | + qbne F, r25, 10 | |
39 | + qbne F, r26, 20 | |
40 | + qbne F, r27, 2 | |
41 | + | |
42 | + pass | |
43 | + | |
44 | +F: fail |
@@ -0,0 +1,89 @@ | ||
1 | +# Check that multiplication works. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + # MUL: Test regular case | |
27 | + ldi r28, 1001 | |
28 | + ldi r29, 4567 | |
29 | + nop | |
30 | + xin 0, r26, 4 | |
31 | + qbne32 2f, r26, 1001 * 4567 | |
32 | + | |
33 | + # MUL: Test the pipeline emulation | |
34 | + ldi r28, 1002 | |
35 | + ldi r29, 1003 | |
36 | + ldi r29, 4004 | |
37 | + xin 0, r26, 4 | |
38 | + qbne32 2f, r26, 1002 * 1003 | |
39 | + xin 0, r26, 4 | |
40 | + qbne32 2f, r26, 1002 * 4004 | |
41 | + | |
42 | + # MUL: Test 64-bit result | |
43 | + ldi32 r28, 0x12345678 | |
44 | + ldi32 r29, 0xaabbccdd | |
45 | + nop | |
46 | + xin 0, r26, 8 | |
47 | + qbne32 2f, r26, 0x45BE4598 | |
48 | + qbne32 2f, r27, 0xC241C38 | |
49 | + | |
50 | + # MAC: Test regular case | |
51 | + ldi r25, 1 | |
52 | + xout 0, r25, 1 | |
53 | + ldi r25, 3 | |
54 | + xout 0, r25, 1 | |
55 | + | |
56 | + ldi r25, 1 | |
57 | + ldi r28, 1001 | |
58 | + ldi r29, 2002 | |
59 | + xout 0, r25, 1 | |
60 | + ldi r28, 3003 | |
61 | + ldi r29, 4004 | |
62 | + xout 0, r25, 1 | |
63 | + | |
64 | + xin 0, r26, 4 | |
65 | + qbne32 2f, r26, (1001 * 2002) + (3003 * 4004) | |
66 | + | |
67 | + # MAC: Test 64-bit result | |
68 | + ldi r25, 3 | |
69 | + xout 0, r25, 1 | |
70 | + | |
71 | + ldi r25, 1 | |
72 | + ldi32 r28, 0x10203040 | |
73 | + ldi32 r29, 0x50607080 | |
74 | + xout 0, r25, 1 | |
75 | + ldi32 r28, 0xa0b0c0d0 | |
76 | + ldi32 r29, 0x11223344 | |
77 | + xout 0, r25, 1 | |
78 | + | |
79 | + xin 0, r26, 8 | |
80 | + qbne32 2f, r26, 0x8E30C740 | |
81 | + qbne32 2f, r27, 0xFD156B1 | |
82 | + | |
83 | + jmp 1f | |
84 | + | |
85 | + fail | |
86 | + | |
87 | +1: | |
88 | + pass | |
89 | +2: fail |
@@ -0,0 +1,40 @@ | ||
1 | +# Check that subregister addressing works. | |
2 | +# mach: pru | |
3 | + | |
4 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
5 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
6 | +# | |
7 | +# This file is part of the GNU simulators. | |
8 | +# | |
9 | +# This program is free software; you can redistribute it and/or modify | |
10 | +# it under the terms of the GNU General Public License as published by | |
11 | +# the Free Software Foundation; either version 3 of the License, or | |
12 | +# (at your option) any later version. | |
13 | +# | |
14 | +# This program is distributed in the hope that it will be useful, | |
15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | +# GNU General Public License for more details. | |
18 | +# | |
19 | +# You should have received a copy of the GNU General Public License | |
20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 | + | |
22 | +.include "testutils.inc" | |
23 | + | |
24 | + start | |
25 | + | |
26 | + ldi r0, 0x01ff | |
27 | + add r0, r0.b0, r0.b1 | |
28 | + qbne F, r0.b0, 0x00 | |
29 | + qbne F, r0.b1, 0x01 | |
30 | + qbne F, r0.w2, 0x00 | |
31 | + | |
32 | + ldi r0, 0x01ff | |
33 | + add r0.b0, r0.b0, r0.b1 | |
34 | + adc r0, r0.b1, r0.b3 | |
35 | + qbne F, r0.b0, 0x02 | |
36 | + qbne F, r0.b1, 0x00 | |
37 | + qbne F, r0.w2, 0x00 | |
38 | + | |
39 | + pass | |
40 | +F: fail |
@@ -0,0 +1,100 @@ | ||
1 | +# Copyright (C) 2016-2019 Free Software Foundation, Inc. | |
2 | +# Contributed by Dimitar Dimitrov <dimitar@dinux.eu> | |
3 | +# | |
4 | +# This file is part of the GNU simulators. | |
5 | +# | |
6 | +# This program is free software; you can redistribute it and/or modify | |
7 | +# it under the terms of the GNU General Public License as published by | |
8 | +# the Free Software Foundation; either version 3 of the License, or | |
9 | +# (at your option) any later version. | |
10 | +# | |
11 | +# This program is distributed in the hope that it will be useful, | |
12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | +# GNU General Public License for more details. | |
15 | +# | |
16 | +# You should have received a copy of the GNU General Public License | |
17 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | + | |
19 | +# MACRO: start | |
20 | +# All assembler tests should start with a call to "main_test" | |
21 | + .macro start | |
22 | + .text | |
23 | + | |
24 | + .global _start | |
25 | +_start: | |
26 | + | |
27 | + # Skip over these inlined funcs. | |
28 | + jmp __main_test; | |
29 | + | |
30 | + .global __pass | |
31 | + .type __pass, function | |
32 | +__pass: | |
33 | + # Note - DRAM LMA and VMA are equal for PRU, so | |
34 | + # we can afford to pass DRAM pointer directly. | |
35 | + write 1, _passmsg, 5 | |
36 | + exit 0 | |
37 | + | |
38 | + .global __fail | |
39 | + .type __fail, function | |
40 | +__fail: | |
41 | + write 1, _failmsg, 5 | |
42 | + exit 1 | |
43 | + | |
44 | + .data | |
45 | +_passmsg: | |
46 | + .ascii "pass\n" | |
47 | + | |
48 | +_failmsg: | |
49 | + .ascii "fail\n" | |
50 | + | |
51 | + .text | |
52 | + .global __main_test | |
53 | + .type __main_test, function | |
54 | +__main_test: | |
55 | + .endm | |
56 | + | |
57 | +# MACRO: system_call | |
58 | +# Make a libgloss system call | |
59 | + .macro system_call nr:req, arg1=0, arg2=0, arg3=0 | |
60 | + ldi r1, \nr | |
61 | + ldi r14, \arg1 | |
62 | + ldi r15, \arg2 | |
63 | + ldi r16, \arg3 | |
64 | + halt | |
65 | + .endm | |
66 | + | |
67 | +# MACRO: exit | |
68 | +# Quit the current test | |
69 | + .macro exit rc:req | |
70 | + system_call 1, \rc | |
71 | + .endm | |
72 | + | |
73 | +# MACRO: pass | |
74 | +# Write 'pass' to stdout via syscalls and quit; | |
75 | +# meant for non-OS operating environments | |
76 | + .macro pass | |
77 | + jmp __pass; | |
78 | + .endm | |
79 | + | |
80 | +# MACRO: fail | |
81 | +# Write 'fail' to stdout via syscalls and quit; | |
82 | +# meant for non-OS operating environments | |
83 | + .macro fail | |
84 | + jmp __fail; | |
85 | + .endm | |
86 | + | |
87 | +# MACRO: write | |
88 | +# Just like the write() C function; uses system calls | |
89 | + .macro write fd:req, str:req, len:req | |
90 | + system_call 5, \fd, \str, \len | |
91 | + .endm | |
92 | + | |
93 | +# MACRO: qbne32 | |
94 | +# Like qbne instruction, but check a 32-bit constant value. | |
95 | + .macro qbne32 label:req, op0:req, C0:req | |
96 | + qbne \label, \op0\().b0, ((\C0) >> 0) & 0xff | |
97 | + qbne \label, \op0\().b1, ((\C0) >> 8) & 0xff | |
98 | + qbne \label, \op0\().b2, ((\C0) >> 16) & 0xff | |
99 | + qbne \label, \op0\().b3, ((\C0) >> 24) & 0xff | |
100 | + .endm |