1 /*-------------------------------------------------------------------
\r
2 -- TITLE: Plasma CPU test code
\r
3 -- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
\r
4 -- DATE CREATED: 4/21/01
\r
6 -- PROJECT: Plasma CPU core
\r
7 -- COPYRIGHT: Software placed into the public domain by the author.
\r
8 -- Software 'as is' without warranty. Author liable for nothing.
\r
10 -- The executable image of this file is used as input to the VHDL.
\r
12 -- This file must not contain any global or static data since
\r
13 -- there isn't a loader to relocate the .data segment and since
\r
14 -- having static data causes the opcodes to begin at a different
\r
15 -- location in the resulting executable file.
\r
17 -- Save the opcodes in "code.txt".
\r
19 -- Testing subversion.
\r
20 --------------------------------------------------------------------*/
\r
23 #define putchar(C) *(volatile unsigned char*)0x20000000=(unsigned char)(C)
\r
26 void print_hex(unsigned long num);
\r
28 char text[]="Testing the Plasma core.\n";
\r
33 char *strcpy2(char *s, const char *t)
\r
36 while((int)(*s++=*t++)) ;
\r
40 static void itoa2(long n, char *s, int base, long *digits)
\r
49 if(n>=0||base!=10) {
\r
55 for(j=14;j>=0;--j) {
\r
58 number[j]=i<10?'0'+i:'a'+i-10;
\r
59 if(n2==0&&15-j>=*digits) break;
\r
64 if(*digits==0||*digits<15-j) {
\r
65 strcpy2(s,&number[j]);
\r
68 strcpy2(s,&number[15-*digits]);
\r
72 void print(long num,long base,long digits)
\r
74 char *ptr,buffer[128];
\r
75 itoa2(num,buffer,base,&digits);
\r
78 putchar(*ptr++); /* Put the character out */
\r
79 if(ptr[-1]=='\n') *--ptr='\r';
\r
83 void print_string(char *p)
\r
94 //show all prime numbers less than 1000
\r
95 for(i=3;i<1000;i+=2) {
\r
115 short short_buf[16];
\r
121 for(i=0;i<32;++i) {
\r
127 for(i=0;i<32;++i) {
\r
133 for(i=0;i<32;++i) {
\r
142 //test multiply and divide
\r
144 for(i=0;i<=10;++i) {
\r
150 for(i=0;i<=5;++i) {
\r
151 print_hex(j*(i+0x12345));
\r
156 for(i=0;i<=5;++i) {
\r
157 print_hex(j*(i+0x123));
\r
162 for(i=1;i<10;++i) {
\r
167 for(i=1;i<10;++i) {
\r
176 //test addition and subtraction
\r
178 for(i=0;i<10;++i) {
\r
183 for(i=0;i<10;++i) {
\r
192 //test bit operations
\r
211 //test memory access
\r
212 for(i=0;i<10;++i) {
\r
217 for(i=0;i<10;++i) {
\r
233 putchar('d'); putchar('o'); putchar('n'); putchar('e'); putchar('\n');
\r