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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [m32r/] [trapmon0.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 joel
/*
2
 * Mon2000 Trap handler (syscall interface).
3
 *
4
 * This trap handler is linked into the mon2000 libgloss (libmon).
5
 */
6
#include <reent.h>
7
#include "syscall.h"
8
 
9
int __trap0 (int function, int p1, int p2, int p3, struct _reent *r)
10
{
11
  int rc = 0;
12
 
13
  switch (function) {
14
  case SYS_exit:
15
    /* loop so GDB can't go past system exit call */
16
    while (1) {
17
      asm volatile ("
18
          ldi     r0, #0
19
          trap    #15        ; return control to Mon2000");
20
    }
21
    break;
22
 
23
  case SYS_write:
24
  {
25
    int i;
26
 
27
    for( i=0; i<p3; i++ ) {
28
      asm volatile ("
29
          ldi   r0, #2
30
          ldi   r1, #15      ; load Ctrl-O (ASCII 15)
31
          trap  #15          ; write Ctrl-O for quoting purposes" );
32
 
33
      asm volatile ("
34
          ldi   r0, #2
35
          ldb   r1, %0
36
          trap  #15          ; write character to console"
37
          : /* no outputs */
38
          : "m" (((char*)p2)[i]));
39
    }
40
 
41
    rc = p3;                 /* return number of chars written */
42
    break;
43
  }
44
 
45
  default:
46
    rc = 0;
47
    break;
48
  }
49
 
50
  return rc;
51
}
52
 
53
 

powered by: WebSVN 2.1.0

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