-
Notifications
You must be signed in to change notification settings - Fork 1
/
2.s
26 lines (22 loc) · 777 Bytes
/
2.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
.global _start
.section .data
filename: .asciz "/path/to/file"
filestat: .skip 144 // space for struct stat
.section .text
_start:
mov x0, filename // filename
mov x1, filestat // struct stat
mov x8, 4 // syscall number for stat
svc 0 // make the system call
ldr x0, [x1, 48] // load st_size field from struct stat
cmp x0, #1024 // compare file size with limit
b.gt delete // if greater, go to delete
exit:
mov x8, 93 // syscall number for exit
mov x0, 0 // exit code
svc 0 // make the system call
delete:
mov x0, filename // filename
mov x8, 87 // syscall number for unlink
svc 0 // make the system call
b exit // go to exit