initial
[fpgammix.git] / workloads / testmem.c
blob033db6891d71c961eecee3650c139324ac97c2bd
1 register volatile int * IOSPACE asm("$233");
3 void putch(long int ch)
5 if (ch == '\n')
6 putch('\r');
7 while (IOSPACE[1])
9 IOSPACE[0] = ch;
12 void puthex(long unsigned d, long unsigned v)
14 if (!d)
15 return;
16 puthex(d - 1, v >> 4);
17 putch("0123456789abcdef"[v & 15]);
20 void my_puts(char *s)
22 while (*s)
23 putch(*s++);
26 register unsigned long g242 asm("$242");
27 register unsigned long g246 asm("$246");
28 register unsigned long g254 asm("$254");
30 void write(unsigned long seg, unsigned long offset, unsigned v)
32 seg <<= 60;
33 seg += offset;
34 *(unsigned *)seg = v;
37 void check(unsigned long seg, unsigned long offset, unsigned v)
39 seg <<= 60;
40 seg += offset;
41 if (*(unsigned *)seg != v) {
42 my_puts("#");
43 puthex(16,seg);
44 my_puts(": ");
45 puthex(8,*(unsigned *)seg);
46 my_puts(" Bad! Expected ");
47 puthex(8, v);
48 putch('\n');
52 int
53 main()
55 // $254 = #60..00
57 g241: 0000000000001a98 _global_impure_ptr = #1a98 (12)
58 g242: 2000000000000000 !!
59 g243: 2000000000001088 _impure_ptr
60 g244: 20000000000017a8 __malloc_av_
61 g245: 2000000000001fb8 __malloc_trim_threshold
62 g246: 4000000000000000 _Sbrk_high !!
63 g247: 0
64 g248: 0
65 g249: 0
66 g250: 0
67 g251: 0
68 g252: 0
69 g253: 0
70 g254: 6000000000000000 !!
71 g255: 0000000000000180 Main
73 int i;
74 IOSPACE = (int*) 0x1000000000000ULL;
75 unsigned long x;
76 unsigned long y;
77 unsigned char *fb;
78 unsigned long k = 128;
79 k <<= 10;
81 g242 = 0x2000000000000000ULL;
82 g246 = 0x4000000000000000ULL;
83 g254 = 0x6000000000000000ULL;
85 //fb = (unsigned char *) (256 * 1024);
87 putch('\n');
88 my_puts("Hello?\n");
89 my_puts("MMIX is **ALIVE**!!\n");
91 write(2, 900, 1729);
92 write(4, 900, 1789);
93 write(6, 900, 666);
95 check(2, 900, 1729);
96 check(4, 900, 1789);
97 check(6, 900, 666);
100 for (x = 9000; x < 256 * 1024; x += 8)
101 write(1, x, 999 + (x << 2) + x);
103 for (x = 9000; x < 256 * 1024; x += 8)
104 check(1, x, 999 + (x << 2) + x);
106 my_puts("Ok\n");