https://github.com/akkartik/mu/blob/main/306files.subx
1
2
3
4
5
6
7
8
9
10 == code
11
12 open:
13
14 55/push-ebp
15 89/<- %ebp 4/r32/esp
16
17 50/push-eax
18 51/push-ecx
19
20 (open-fd *(ebp+8) *(ebp+0xc))
21 89/<- %ecx 0/r32/eax
22
23 3d/compare-eax-with 0/imm32
24 7c/jump-if-< $open:end/disp8
25
26 (allocate Heap 0x1010 *(ebp+0x10))
27
28 8b/-> *(ebp+0x10) 0/r32/eax
29 (lookup *eax *(eax+4))
30
31 c7 0/subop/copy *(eax+0xc) 0x1000/imm32/file-buffer-size
32
33 89/<- *eax 1/r32/ecx
34 $open:end:
35
36 59/pop-to-ecx
37 58/pop-to-eax
38
39 89/<- %esp 5/r32/ebp
40 5d/pop-to-ebp
41 c3/return
42
43 open-fd:
44
45 55/push-ebp
46 89/<- %ebp 4/r32/esp
47
48 51/push-ecx
49 52/push-edx
50 53/push-ebx
51 56/push-esi
52
53 8b/-> *(ebp+8) 1/r32/ecx
54
55 8b/-> *ecx 2/r32/edx
56 42/increment-edx
57
58 29/subtract-from %esp 2/r32/edx
59 52/push-edx
60 68/push 0/imm32/read
61 68/push 0/imm32/write
62 89/<- %esi 4/r32/esp
63
64 (clear-stream %esi)
65 (write %esi %ecx)
66
67 52/push-edx
68
69 8d/copy-address *(esi+0xc) 3/r32/ebx
70 8b/-> *(ebp+0xc) 1/r32/ecx/flags
71 ba/copy-to-edx 0x180/imm32/permissions
72 e8/call syscall_open/disp32
73
74 5a/pop-to-edx
75 $open-fd:end:
76
77 01/add-to %esp 2/r32/edx
78 81 0/subop/add %esp 0xc/imm32
79
80 5e/pop-to-esi
81 5b/pop-to-ebx
82 5a/pop-to-edx
83 59/pop-to-ecx
84
85 89/<- %esp 5/r32/ebp
86 5d/pop-to-ebp
87 c3/return
88
89 populate-buffered-file-containing:
90
91 55/push-ebp
92 89/<- %ebp 4/r32/esp
93
94 50/push-eax
95 51/push-ecx
96 56/push-esi
97 57/push-edi
98
99 8b/-> *(ebp+8) 6/r32/esi
100
101 8b/-> *esi 1/r32/ecx
102
103 68/push 0/imm32
104 68/push 0/imm32
105 89/<- %edi 4/r32/esp
106
107 (new-stream Heap %ecx 1 %edi)
108
109 (lookup *edi *(edi+4))
110 89/<- %edi 0/r32/eax
111
112 (write %edi %esi)
113
114 (allocate Heap 0x110 *(ebp+0xc))
115
116 8b/-> *(ebp+0xc) 0/r32/eax
117 (lookup *eax *(eax+4))
118
119 c7 0/subop/copy *(eax+0xc) 0x100/imm32/file-buffer-size
120
121 89/<- *eax 7/r32/edi
122 $populate-buffered-file-containing:end:
123
124 81 0/subop/add %esp 8/imm32
125
126 5f/pop-to-edi
127 5e/pop-to-esi
128 59/pop-to-ecx
129 58/pop-to-eax
130
131 89/<- %esp 5/r32/ebp
132 5d/pop-to-ebp
133 c3/return
134
135 new-buffered-file:
136
137 55/push-ebp
138 89/<- %ebp 4/r32/esp
139
140 50/push-eax
141 51/push-ecx
142
143 68/push 0/imm32
144 68/push 0/imm32
145 89/<- %ecx 4/r32/esp
146
147 (new-stream Heap 0x100 1 %ecx)
148
149 (lookup *ecx *(ecx+4))
150 89/<- %ecx 0/r32/eax
151
152 (allocate Heap 0x110 *(ebp+8))
153
154 8b/-> *(ebp+8) 0/r32/eax
155 (lookup *eax *(eax+4))
156
157 c7 0/subop/copy *(eax+0xc) 0x100/imm32/file-buffer-size
158
159 89/<- *eax 1/r32/ecx
160 $new-buffered-file:end:
161
162 81 0/subop/add %esp 8/imm32
163
164 59/pop-to-ecx
165 58/pop-to-eax
166
167 89/<- %esp 5/r32/ebp
168 5d/pop-to-ebp
169 c3/return