aboutsummaryrefslogtreecommitdiff
path: root/libgloss/xstormy16/syscalls.S
blob: 8f4175f310c2206263b365ffd5255c5db38fb14d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# xstormy16 system calls for the simulator

#include <syscall.h>

	.text

	.globl _exit
_exit:
	mov r1,#SYS_exit
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size exit,0b-_exit

	.globl _open
_open:
	mov r1,#SYS_open
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size open,0b-_open

	.globl _close
_close:
	mov r1,#SYS_close
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size close,0b-_close

	.globl _read
_read:
	mov r1,#SYS_read
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size read,0b-_read

	.globl _write
_write:
	mov r1,#SYS_write
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size write,0b-_write

	.globl _lseek
_lseek:
	mov r1,#SYS_lseek
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size lseek,0b-_lseek

	.globl _unlink
_unlink:
	mov r1,#SYS_unlink
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size unlink,0b-_unlink

	.globl _getpid
_getpid:
	mov r1,#SYS_getpid
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size getpid,0b-_getpid

	.globl _kill
_kill:
	mov r1,#SYS_kill
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size kill,0b-_kill

	.globl _fstat
_fstat:
	mov r1,#SYS_fstat
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size fstat,0b-_fstat

	.globl _chdir
_chdir:
	mov r1,#SYS_chdir
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size chdir,0b-_chdir

	.globl _stat
_stat:
	mov r1,#SYS_stat
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size stat,0b-_stat

	.globl _chmod
_chmod:
	mov r1,#SYS_chmod
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size chmod,0b-_chmod

	.globl _utime
_utime:
	mov r1,#SYS_utime
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size utime,0b-_utime

	.globl _time
_time:
	mov r1,#SYS_time
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size time,0b-_time

	.globl _gettimeofday
_gettimeofday:
	mov r1,#SYS_gettimeofday
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size gettimeofday,0b-_gettimeofday

	.globl _times
_times:
	mov r1,#SYS_times
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size times,0b-_times

	.globl _link
_link:
	mov r1,#SYS_link
	.hword 0x0001
	bnz r1,#0,syscall_error
	ret
0:	.size link,0b-_link

syscall_error:
# Return value for the syscall is in r2.  Save it here, as
# _errno will overwrite it with the address of the errno
# variable.  r0 is the errno.
	push r2
	push r0
	callf __errno
	pop r0
	mov.w (r2),r0
	pop r2
	ret
0:	.size syscall_error,0b-syscall_error