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 (allocate Heap 0x1010 *(ebp+0x10))
49
50 8b/-> *(ebp+0x10) 7/r32/edi
51 (lookup *edi *(edi+4))
52 89/<- %edi 0/r32/eax
53
54 c7 0/subop/copy *(edi+0xc) 0x1000/imm32/file-buffer-size
55
56 89/<- *edi 1/r32/ecx
57 $open:end:
58
59 01/add-to %esp 2/r32/edx
60 81 0/subop/add %esp 0xc/imm32
61
62 5f/pop-to-edi
63 5e/pop-to-esi
64 5b/pop-to-ebx
65 5a/pop-to-edx
66 59/pop-to-ecx
67 58/pop-to-eax
68
69 89/<- %esp 5/r32/ebp
70 5d/pop-to-ebp
71 c3/return
72
73 populate-buffered-file-containing:
74
75 55/push-ebp
76 89/<- %ebp 4/r32/esp
77
78 50/push-eax
79 51/push-ecx
80 56/push-esi
81 57/push-edi
82
83 8b/-> *(ebp+8) 6/r32/esi
84
85 8b/-> *esi 1/r32/ecx
86
87 68/push 0/imm32
88 68/push 0/imm32
89 89/<- %edi 4/r32/esp
90
91 (new-stream Heap %ecx 1 %edi)
92
93 (lookup *edi *(edi+4))
94 89/<- %edi 0/r32/eax
95
96 (write %edi %esi)
97
98 (allocate Heap 0x110 *(ebp+0xc))
99
100 8b/-> *(ebp+0xc) 0/r32/eax
101 (lookup *eax *(eax+4))
102
103 c7 0/subop/copy *(eax+0xc) 0x100/imm32/file-buffer-size
104
105 89/<- *eax 7/r32/edi
106 $populate-buffered-file-containing:end:
107
108 81 0/subop/add %esp 8/imm32
109
110 5f/pop-to-edi
111 5e/pop-to-esi
112 59/pop-to-ecx
113 58/pop-to-eax
114
115 89/<- %esp 5/r32/ebp
116 5d/pop-to-ebp
117 c3/return
118
119 new-buffered-file:
120
121 55/push-ebp
122 89/<- %ebp 4/r32/esp
123
124 50/push-eax
125 51/push-ecx
126
127 68/push 0/imm32
128 68/push 0/imm32
129 89/<- %ecx 4/r32/esp
130
131 (new-stream Heap 0x100 1 %ecx)
132
133 (lookup *ecx *(ecx+4))
134 89/<- %ecx 0/r32/eax
135
136 (allocate Heap 0x110 *(ebp+8))
137
138 8b/-> *(ebp+8) 0/r32/eax
139 (lookup *eax *(eax+4))
140
141 c7 0/subop/copy *(eax+0xc) 0x100/imm32/file-buffer-size
142
143 89/<- *eax 1/r32/ecx
144 $new-buffered-file:end:
145
146 81 0/subop/add %esp 8/imm32
147
148 59/pop-to-ecx
149 58/pop-to-eax
150
151 89/<- %esp 5/r32/ebp
152 5d/pop-to-ebp
153 c3/return