-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestfs.s
73 lines (63 loc) · 902 Bytes
/
testfs.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
71
72
.section .data
.global testfsmeta
testfsmeta:
.long fs
fs:
.long 2
.long 2
.long table
.long 0
table:
.ascii "testf\0"
.long endtestf-testf
.long testf
.ascii "progm\0"
.long endprogm-progm
.long progm
testf:
.ascii "this is a test file\n"
endtestf:
.byte 0
progm:
push %ebp
movl %esp, %ebp
push %eax
push %ebx
push %ecx
push %esi
push %edi
# print args
movl $0x2, %eax
movl $0x1, %ebx
movl $0x0, %ecx
movl 0x8(%ebp), %esi
movl 0xc(%ebp), %edx # print arg len
int $0xCD
# dump input registers
movl $0x10, %eax
movl $0x5, %ebx
movl $0x6, %ecx
int $0xCD
# getc
movl $0x1, %eax
movl $0x0, %ebx
movl $0x0, %ecx
leal -0x4(%esp), %edi
movl $0x1, %edx
int $0xCD
# putc
movl $0x2, %eax
movl $0x1, %ebx
movl $0x0, %ecx
leal -0x4(%esp), %esi
movl $0x1, %edx
int $0xCD
pop %edi
pop %esi
pop %ecx
pop %ebx
pop %eax
pop %ebp
ret
endprogm:
.byte 0