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