Memory: Change offset latch in LDM so that there is no flutter if DCache cannot get...
[firearm.git] / tests / testbench.c
1 extern void putc(unsigned char c);
2
3 void puts(unsigned char *s)
4 {
5         while (*s)
6                 putc(*(s++));
7 }
8
9 void puthex(unsigned int x)
10 {
11         unsigned char *hex = "0123456789ABCDEF";
12         int i;
13         
14         for (i = 7; i >= 0; i--)
15                 putc(hex[(x >> (i * 4)) & 0xF]);
16 }
17
18 #define putchar putc
19 #include "ack.c"
20 #include "j4cbo.c"
21 #include "corecurse.c"
22
23 int fact(int n)
24 {
25         if (n == 0)
26                 return 1;
27         else
28                 return n * fact(n-1);
29 }
30
31 void facttest()
32 {
33         if (fact(10) != 3628800)
34                 puts("FAIL\n");
35         else
36                 puts("PASS\n");
37 }
38
39 struct tests {
40         char *name;
41         void (*test)();
42 };
43
44 extern int ldm_bonehead();
45 #ifndef X86
46 __asm__(
47 ".globl ldm_bonehead\n"
48 "ldm_bonehead:;"
49 "mov r3, lr;"
50 "bl 1f;"
51 "nop;"
52 "nop;"
53 "nop;"
54 "nop;"
55 "nop;"
56 "nop;"
57 "nop;"
58 "nop;"
59 "nop;"
60 "mov pc, r3\n;"
61 "1:\n"
62 "ldr r2, =0x00002FE0;"
63 "ldr r1, =0x0000004C;"
64 "mov ip, sp;"
65 "stmdb sp!, {fp, ip, lr, pc};"
66 "mov r0, #0x00880000;"
67 "ldmia sp, {fp, sp, pc};"
68 "mul r0, r1, r2;"
69 "nop;"
70 "nop;\n"
71 );
72 #endif
73 void ldm_tester()
74 {
75 #ifdef X86
76         int x = 0x00880000;
77 #else
78         int x = ldm_bonehead();
79 #endif
80         if (x != 0x00880000)
81         {
82                 puts("FAIL: result was ");
83                 puthex(x);
84                 puts("\n");
85         } else
86                 puts("PASS\n");
87 }
88
89 struct tests tlist[] = {
90         {"ldm pc/mul", ldm_tester},
91         {"fact", facttest},
92         {"j4cbo", j4cbo},
93         {"ack", acktest},
94         {"corecurse", corecurse},
95         {0, 0}};
96
97 int main()
98 {
99         struct tests *t;
100         
101         puts("Testbench running\n");
102         
103         for (t = tlist; t->name; t++)
104         {
105                 puts("Running ");
106                 puts(t->name);
107                 puts(": ");
108                 t->test();
109         }
110         puts("Done!\n");
111         
112         return 0;
113 }
This page took 0.026727 seconds and 4 git commands to generate.