-
Notifications
You must be signed in to change notification settings - Fork 1
/
sys-linux-arm.S
70 lines (58 loc) · 1.29 KB
/
sys-linux-arm.S
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
.globl _start
.set STDIN_FILENO , 0
.set STDOUT_FILENO , 1
.set sys_exit , 1
.set sys_read , 3
.set sys_write , 4
.set sys_open , 5
.set sys_close , 6
.thumb_func
_start:
ldr r0, [sp]
add r1, sp, #4
ldr r2, =ArgC
str r0, [r2]
ldr r2, =ArgV
str r1, [r2]
mov r0, #STDIN_FILENO
ldr r1, =StdinFile
str r0, [r1]
mov r0, #STDOUT_FILENO
ldr r1, =StdoutFile
str r0, [r1]
b StartInterpreter
.thumb_func
// R0 = Exit code
NativeExit:
mov r7, #sys_exit
swi #0
bkpt
.thumb_func
// R0 = FileName, R1 = Flags
NativeOpen:
push {r7,lr}
mov r7, #sys_open
mov r2, #0
swi #0
pop {r7,pc}
.thumb_func
// R0 = fd
NativeClose:
push {r7,lr}
mov r7, #sys_close
swi #0
pop {r7,pc}
.thumb_func
// R0 = fd, R1 = buffer, R2 = count
NativeRead:
push {r7,lr}
mov r7, #sys_read
swi #0
pop {r7,pc}
.thumb_func
// R0 = fd, R1 = buffer, R2 = count
NativeWrite:
push {r7,lr}
mov r7, #sys_write
swi #0
pop {r7,pc}