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

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [support/] [support.c] - Diff between revs 1422 and 1578

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

Rev 1422 Rev 1578
Line 31... Line 31...
}
}
 
 
/* return value by making a syscall */
/* return value by making a syscall */
void exit (int i)
void exit (int i)
{
{
  asm("l.add r3,r0,%0": : "r" (i));
  __asm__ __volatile__ ("l.add r3,r0,%0\n\t"
  asm("l.nop %0": :"K" (NOP_EXIT));
                        "l.nop %1": : "r" (i), "K" (NOP_EXIT));
  while (1);
  while (1);
}
}
 
 
/* activate printf support in simulator */
/* activate printf support in simulator */
void printf(const char *fmt, ...)
void printf(const char *fmt, ...)
{
{
  va_list args;
  va_list args;
  va_start(args, fmt);
  va_start(args, fmt);
  __asm__ __volatile__ ("  l.addi\tr3,%0,0\n": : "r" (fmt) : "r3", "r4");
  __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
  __asm__ __volatile__ ("  l.addi\tr4,%0,0\n": : "r" (args): "r3", "r4");
                        "l.addi\tr4,%1,0\n\t"
  __asm__ __volatile__ ("  l.nop  %0": : "K" (NOP_PRINTF));
                        "l.nop  %2"
 
                        : : "r" (fmt), "r" (args), "K" (NOP_PRINTF)
 
                        : "r3", "r4");
}
}
 
 
/* print long */
/* print long */
void report(unsigned long value)
void report(unsigned long value)
{
{
  asm("l.addi\tr3,%0,0": :"r" (value));
  __asm__ __volatile__ ("l.addi\tr3,%0,0\n\t"
  asm("l.nop %0": :"K" (NOP_REPORT));
                        "l.nop %1": : "r" (value), "K" (NOP_REPORT));
}
}
 
 
/* just to satisfy linker */
/* just to satisfy linker */
void __main()
void __main()
{
{
Line 78... Line 80...
}
}
 
 
/* For writing into SPR. */
/* For writing into SPR. */
void mtspr(unsigned long spr, unsigned long value)
void mtspr(unsigned long spr, unsigned long value)
{
{
  asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
  __asm__ __volatile__ ("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value));
}
}
 
 
/* For reading SPR. */
/* For reading SPR. */
unsigned long mfspr(unsigned long spr)
unsigned long mfspr(unsigned long spr)
{
{
  unsigned long value;
  unsigned long value;
  asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
  __asm__ __volatile__ ("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr));
  return value;
  return value;
}
}
 
 
#else
#else
void report(unsigned long value)
void report(unsigned long value)

powered by: WebSVN 2.1.0

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