Last change
on this file since 548 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
2.3 KB
|
Rev | Line | |
---|
[444] | 1 | # xstormy16 system calls for the simulator |
---|
| 2 | |
---|
| 3 | #include <syscall.h> |
---|
| 4 | |
---|
| 5 | .text |
---|
| 6 | |
---|
| 7 | .globl _exit |
---|
| 8 | _exit: |
---|
| 9 | mov r1,#SYS_exit |
---|
| 10 | .hword 0x0001 |
---|
| 11 | bnz r1,#0,syscall_error |
---|
| 12 | ret |
---|
| 13 | 0: .size exit,0b-_exit |
---|
| 14 | |
---|
| 15 | .globl _open |
---|
| 16 | _open: |
---|
| 17 | mov r1,#SYS_open |
---|
| 18 | .hword 0x0001 |
---|
| 19 | bnz r1,#0,syscall_error |
---|
| 20 | ret |
---|
| 21 | 0: .size open,0b-_open |
---|
| 22 | |
---|
| 23 | .globl _close |
---|
| 24 | _close: |
---|
| 25 | mov r1,#SYS_close |
---|
| 26 | .hword 0x0001 |
---|
| 27 | bnz r1,#0,syscall_error |
---|
| 28 | ret |
---|
| 29 | 0: .size close,0b-_close |
---|
| 30 | |
---|
| 31 | .globl _read |
---|
| 32 | _read: |
---|
| 33 | mov r1,#SYS_read |
---|
| 34 | .hword 0x0001 |
---|
| 35 | bnz r1,#0,syscall_error |
---|
| 36 | ret |
---|
| 37 | 0: .size read,0b-_read |
---|
| 38 | |
---|
| 39 | .globl _write |
---|
| 40 | _write: |
---|
| 41 | mov r1,#SYS_write |
---|
| 42 | .hword 0x0001 |
---|
| 43 | bnz r1,#0,syscall_error |
---|
| 44 | ret |
---|
| 45 | 0: .size write,0b-_write |
---|
| 46 | |
---|
| 47 | .globl _lseek |
---|
| 48 | _lseek: |
---|
| 49 | mov r1,#SYS_lseek |
---|
| 50 | .hword 0x0001 |
---|
| 51 | bnz r1,#0,syscall_error |
---|
| 52 | ret |
---|
| 53 | 0: .size lseek,0b-_lseek |
---|
| 54 | |
---|
| 55 | .globl _unlink |
---|
| 56 | _unlink: |
---|
| 57 | mov r1,#SYS_unlink |
---|
| 58 | .hword 0x0001 |
---|
| 59 | bnz r1,#0,syscall_error |
---|
| 60 | ret |
---|
| 61 | 0: .size unlink,0b-_unlink |
---|
| 62 | |
---|
| 63 | .globl _getpid |
---|
| 64 | _getpid: |
---|
| 65 | mov r1,#SYS_getpid |
---|
| 66 | .hword 0x0001 |
---|
| 67 | bnz r1,#0,syscall_error |
---|
| 68 | ret |
---|
| 69 | 0: .size getpid,0b-_getpid |
---|
| 70 | |
---|
| 71 | .globl _kill |
---|
| 72 | _kill: |
---|
| 73 | mov r1,#SYS_kill |
---|
| 74 | .hword 0x0001 |
---|
| 75 | bnz r1,#0,syscall_error |
---|
| 76 | ret |
---|
| 77 | 0: .size kill,0b-_kill |
---|
| 78 | |
---|
| 79 | .globl _fstat |
---|
| 80 | _fstat: |
---|
| 81 | mov r1,#SYS_fstat |
---|
| 82 | .hword 0x0001 |
---|
| 83 | bnz r1,#0,syscall_error |
---|
| 84 | ret |
---|
| 85 | 0: .size fstat,0b-_fstat |
---|
| 86 | |
---|
| 87 | .globl _chdir |
---|
| 88 | _chdir: |
---|
| 89 | mov r1,#SYS_chdir |
---|
| 90 | .hword 0x0001 |
---|
| 91 | bnz r1,#0,syscall_error |
---|
| 92 | ret |
---|
| 93 | 0: .size chdir,0b-_chdir |
---|
| 94 | |
---|
| 95 | .globl _stat |
---|
| 96 | _stat: |
---|
| 97 | mov r1,#SYS_stat |
---|
| 98 | .hword 0x0001 |
---|
| 99 | bnz r1,#0,syscall_error |
---|
| 100 | ret |
---|
| 101 | 0: .size stat,0b-_stat |
---|
| 102 | |
---|
| 103 | .globl _chmod |
---|
| 104 | _chmod: |
---|
| 105 | mov r1,#SYS_chmod |
---|
| 106 | .hword 0x0001 |
---|
| 107 | bnz r1,#0,syscall_error |
---|
| 108 | ret |
---|
| 109 | 0: .size chmod,0b-_chmod |
---|
| 110 | |
---|
| 111 | .globl _utime |
---|
| 112 | _utime: |
---|
| 113 | mov r1,#SYS_utime |
---|
| 114 | .hword 0x0001 |
---|
| 115 | bnz r1,#0,syscall_error |
---|
| 116 | ret |
---|
| 117 | 0: .size utime,0b-_utime |
---|
| 118 | |
---|
| 119 | .globl _time |
---|
| 120 | _time: |
---|
| 121 | mov r1,#SYS_time |
---|
| 122 | .hword 0x0001 |
---|
| 123 | bnz r1,#0,syscall_error |
---|
| 124 | ret |
---|
| 125 | 0: .size time,0b-_time |
---|
| 126 | |
---|
| 127 | .globl _gettimeofday |
---|
| 128 | _gettimeofday: |
---|
| 129 | mov r1,#SYS_gettimeofday |
---|
| 130 | .hword 0x0001 |
---|
| 131 | bnz r1,#0,syscall_error |
---|
| 132 | ret |
---|
| 133 | 0: .size gettimeofday,0b-_gettimeofday |
---|
| 134 | |
---|
| 135 | .globl _times |
---|
| 136 | _times: |
---|
| 137 | mov r1,#SYS_times |
---|
| 138 | .hword 0x0001 |
---|
| 139 | bnz r1,#0,syscall_error |
---|
| 140 | ret |
---|
| 141 | 0: .size times,0b-_times |
---|
| 142 | |
---|
| 143 | .globl _link |
---|
| 144 | _link: |
---|
| 145 | mov r1,#SYS_link |
---|
| 146 | .hword 0x0001 |
---|
| 147 | bnz r1,#0,syscall_error |
---|
| 148 | ret |
---|
| 149 | 0: .size link,0b-_link |
---|
| 150 | |
---|
| 151 | syscall_error: |
---|
| 152 | # Return value for the syscall is in r2. Save it here, as |
---|
| 153 | # _errno will overwrite it with the address of the errno |
---|
| 154 | # variable. r0 is the errno. |
---|
| 155 | push r2 |
---|
| 156 | push r0 |
---|
| 157 | callf __errno |
---|
| 158 | pop r0 |
---|
| 159 | mov.w (r2),r0 |
---|
| 160 | pop r2 |
---|
| 161 | ret |
---|
| 162 | 0: .size syscall_error,0b-syscall_error |
---|
Note: See
TracBrowser
for help on using the repository browser.