Line 12... |
Line 12... |
-- This file must not contain any global or static data since
|
-- This file must not contain any global or static data since
|
-- there isn't a loader to relocate the .data segment and since
|
-- there isn't a loader to relocate the .data segment and since
|
-- having static data causes the opcodes to begin at a different
|
-- having static data causes the opcodes to begin at a different
|
-- location in the resulting executable file.
|
-- location in the resulting executable file.
|
--
|
--
|
-- After being compiled with the Microsoft MIPS compiler, the program
|
-- Save the opcodes in "code.txt".
|
-- convert will pull out the MIPS opcodes, and switch the executable
|
|
-- to Big Endian, and convert absolute jumps into relative jumps,
|
|
-- and save the opcodes in "code.txt".
|
|
--
|
--
|
-- The interrupt vector is set to address 0x30.
|
-- The interrupt vector is set to address 0x30.
|
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
#ifdef MIPS
|
#ifdef MIPS
|
#undef putchar
|
#undef putchar
|
// The MIPS CPU VHDL supports a virtual UART. All character writes
|
// The MIPS CPU VHDL supports a virtual UART. All character writes
|
// to address 0xffff will be stored in the file "output.txt".
|
// to address 0xffff will be stored in the file "output.txt".
|
#define putchar(C) *(volatile unsigned char*)0xffff=(unsigned char)(C)
|
#define putchar(C) *(volatile unsigned char*)0xffff=(unsigned char)(C)
|
|
void isr_enable(int);
|
|
#else
|
|
#define isr_enable(A)
|
#endif
|
#endif
|
|
|
|
char text[]="Testing the MIPS-lite core.\n";
|
|
char buf[20];
|
|
int xyz=0xbadbeef;
|
|
int abc;
|
|
|
char *strcpy2(char *s, const char *t)
|
char *strcpy2(char *s, const char *t)
|
{
|
{
|
char *tmp=s;
|
char *tmp=s;
|
while((int)(*s++=*t++)) ;
|
while((int)(*s++=*t++)) ;
|
return(tmp);
|
return(tmp);
|
Line 67... |
Line 72... |
}
|
}
|
}
|
}
|
|
|
void print(long num,long base,long digits)
|
void print(long num,long base,long digits)
|
{
|
{
|
volatile unsigned char *uart_base = (unsigned char *)0xffff;
|
|
char *ptr,buffer[128];
|
char *ptr,buffer[128];
|
itoa2(num,buffer,base,&digits);
|
itoa2(num,buffer,base,&digits);
|
ptr=buffer;
|
ptr=buffer;
|
while(*ptr) {
|
while(*ptr) {
|
putchar(*ptr++); /* Put the character out */
|
putchar(*ptr++); /* Put the character out */
|
Line 91... |
Line 95... |
}
|
}
|
|
|
void print_string(char *p)
|
void print_string(char *p)
|
{
|
{
|
int i;
|
int i;
|
for(i=0;i<50;++i) {
|
for(i=0;p[i];++i) {
|
if(p[i]==0) break;
|
|
putchar(p[i]);
|
putchar(p[i]);
|
}
|
}
|
}
|
}
|
|
|
int prime()
|
int prime()
|
{
|
{
|
int i,j,k;
|
int i,j;
|
//show all prime numbers less than 1000
|
//show all prime numbers less than 1000
|
for(i=3;i<1000;i+=2) {
|
for(i=3;i<1000;i+=2) {
|
for(j=3;j<i;j+=2) {
|
for(j=3;j<i;j+=2) {
|
if(i%j==0) {
|
if(i%j==0) {
|
j=0;
|
j=0;
|
Line 119... |
Line 122... |
return 0;
|
return 0;
|
}
|
}
|
|
|
int main2()
|
int main2()
|
{
|
{
|
long i,j,k;
|
long i,j;
|
unsigned long m;
|
|
char char_buf[16];
|
char char_buf[16];
|
char buf2[16];
|
|
short short_buf[16];
|
short short_buf[16];
|
long long_buf[16];
|
long long_buf[16];
|
|
|
|
//Uncomment to test interrupts
|
|
// isr_enable(1);
|
|
|
#if 1
|
#if 1
|
//test shift
|
//test shift
|
j=0x12345678;
|
j=0x12345678;
|
for(i=0;i<32;++i) {
|
for(i=0;i<32;++i) {
|
print_hex(j>>i);
|
print_hex(j>>i);
|