OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [tools/] [test.c] - Diff between revs 7 and 21

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 7 Rev 21
Line 19... Line 19...
--   to Big Endian, and convert absolute jumps into relative jumps,
--   to Big Endian, and convert absolute jumps into relative jumps,
--   and save the opcodes in "code.txt".
--   and save the opcodes in "code.txt".
--
--
--   The interrupt vector is set to address 0x30.
--   The interrupt vector is set to address 0x30.
--------------------------------------------------------------------*/
--------------------------------------------------------------------*/
#ifdef SIMULATE
#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)
#endif
#endif
 
 
//The main entry point must be the first function
 
//The program convert will change the first opcode to setting 
 
//the stack pointer.
 
int main()
 
{
 
   int main2();
 
#ifdef MIPS
 
   __asm(".set noreorder");
 
   //The convertion tool will add two opcodes here
 
   __asm("ori $4,$0,0x1");
 
   __asm("mtc0 $4,$12");  //STATUS=1; enable interrupts
 
   __asm(".set reorder");
 
#endif
 
 
 
   main2();
 
 
 
#ifdef MIPS
 
   __asm(".set noreorder");
 
   __asm("nop");
 
 
 
   /*address 0x20 used for storing ISR register values*/
 
   __asm("nop");
 
   __asm("nop");
 
   __asm("nop");
 
   __asm("nop");
 
   __asm("nop");
 
 
 
   /*address 0x30 interrupt service routine*/
 
   __asm("sw $4,0x20($0)");
 
   __asm("sw $5,0x24($0)");
 
 
 
   __asm("ori $5,$0,0xffff");
 
   __asm("ori $4,$0,46");
 
//   __asm("sb $4,0($5)");   /*echo out '.'*/
 
   __asm("nop");
 
 
 
   /*normally clear the interrupt source here*/
 
   /*re-enable interrupts*/
 
   __asm("ori $4,$0,0x1");
 
   __asm("mtc0 $4,$12");   //STATUS=1; enable interrupts
 
   __asm("mfc0 $4, $14");  //C0_EPC=14
 
   __asm("nop");
 
   __asm("lw $5,0x24($0)");
 
   __asm("j $4");
 
   __asm("lw $4,0x20($0)");
 
   __asm(".set reorder");
 
#endif
 
}
 
 
 
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 87... Line 38...
static void itoa2(long n, char *s, int base, long *digits)
static void itoa2(long n, char *s, int base, long *digits)
{
{
   long i,j,sign;
   long i,j,sign;
   unsigned long n2;
   unsigned long n2;
   char number[20];
   char number[20];
   for(i=0;i<15;++i) number[i]=' ';
   for(i=0;i<15;++i) {
 
      number[i]=' ';
 
   }
   number[15]=0;
   number[15]=0;
   if(n>=0||base!=10) sign=1;
   if(n>=0||base!=10) {
   else sign=-1;
      sign=1;
 
   } else {
 
      sign=-1;
 
   }
   n2=n*sign;
   n2=n*sign;
   for(j=14;j>=0;--j) {
   for(j=14;j>=0;--j) {
      i=n2%base;
      i=n2%base;
      n2/=base;
      n2/=base;
      number[j]=i<10?'0'+i:'a'+i-10;
      number[j]=i<10?'0'+i:'a'+i-10;
Line 132... Line 88...
      if(j<10) putchar('0'+j);
      if(j<10) putchar('0'+j);
      else putchar('a'-10+j);
      else putchar('a'-10+j);
   }
   }
}
}
 
 
 
void print_string(char *p)
 
{
 
   int i;
 
   for(i=0;i<50;++i) {
 
      if(p[i]==0) break;
 
      putchar(p[i]);
 
   }
 
}
 
 
int prime()
int prime()
{
{
   int i,j,k;
   int i,j,k;
   //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) {
Line 157... Line 122...
int main2()
int main2()
{
{
   long i,j,k;
   long i,j,k;
   unsigned long m;
   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];
 
 
#if 1 
#if 1 
   //test shift
   //test shift

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.