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