https://github.com/akkartik/mu/blob/main/baremetal/108write.subx
1
2
3
4
5 write:
6
7 55/push-ebp
8 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
9
10 81 7/subop/compare 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 0/imm32
11 74/jump-if-= $write:end/disp8
12
13
14
15 50/push-eax
16 51/push-ecx
17 52/push-edx
18 53/push-ebx
19
20 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 1/r32/ecx 8/disp8 .
21
22 8b/copy 0/mod/indirect 1/rm32/ecx . . . 2/r32/edx . .
23
24 8b/copy 1/mod/*+disp8 1/rm32/ecx . . . 3/r32/ebx 8/disp8 .
25
26
27 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
28
29 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ecx 3/index/ebx . 3/r32/ebx 0xc/disp8 .
30 53/push-ebx
31
32 8d/copy-address 1/mod/*+disp8 4/rm32/sib 1/base/ecx 2/index/edx . 3/r32/ebx 0xc/disp8 .
33 53/push-ebx
34
35 e8/call _append-3/disp32
36
37 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
38
39 01/add 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
40
41 5b/pop-to-ebx
42 5a/pop-to-edx
43 59/pop-to-ecx
44 58/pop-to-eax
45 $write:end:
46
47 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
48 5d/pop-to-ebp
49 c3/return
50
51
52
53
54 _append-3:
55
56 55/push-ebp
57 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
58
59 51/push-ecx
60
61
62 8b/copy 1/mod/*+disp8 5/rm32/ebp . . 0/r32/eax 0x10/disp8 .
63 8b/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
64 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 1/index/ecx . 1/r32/ecx 4/disp8 .
65 51/push-ecx
66
67 8d/copy-address 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 .
68 51/push-ecx
69
70 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
71
72 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
73
74 e8/call _append-4/disp32
75
76 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
77 $_append-3:end:
78
79 59/pop-to-ecx
80
81 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
82 5d/pop-to-ebp
83 c3/return
84
85
86 _append-4:
87
88 55/push-ebp
89 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
90
91 51/push-ecx
92 52/push-edx
93 53/push-ebx
94 56/push-esi
95 57/push-edi
96
97 b8/copy-to-eax 0/imm32
98
99 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
100
101 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
102
103 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0x10/disp8 .
104
105 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0x14/disp8 .
106 $_append-4:loop:
107
108 39/compare 3/mod/direct 6/rm32/esi . . . 1/r32/ecx . .
109 73/jump-if-addr>= $_append-4:end/disp8
110
111 39/compare 3/mod/direct 7/rm32/edi . . . 2/r32/edx . .
112 73/jump-if-addr>= $_append-4:end/disp8
113
114 8a/copy-byte 0/mod/indirect 6/rm32/esi . . . 3/r32/BL . .
115 88/copy-byte 0/mod/indirect 7/rm32/edi . . . 3/r32/BL . .
116
117 40/increment-eax
118
119 46/increment-esi
120
121 47/increment-edi
122 eb/jump $_append-4:loop/disp8
123 $_append-4:end:
124
125 5f/pop-to-edi
126 5e/pop-to-esi
127 5b/pop-to-ebx
128 5a/pop-to-edx
129 59/pop-to-ecx
130
131 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
132 5d/pop-to-ebp
133 c3/return
134
135