Last change
on this file since 571 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.1 KB
|
Rev | Line | |
---|
[444] | 1 | /* |
---|
| 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 \n" |
---|
| 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 \n" |
---|
| 30 | "ldi r1, #15 ; load Ctrl-O (ASCII 15) \n" |
---|
| 31 | "trap #15 ; write Ctrl-O for quoting purposes" ); |
---|
| 32 | |
---|
| 33 | asm volatile ( |
---|
| 34 | "ldi r0, #2 \n" |
---|
| 35 | "ldb r1, %0 \n" |
---|
| 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 | |
---|
Note: See
TracBrowser
for help on using the repository browser.