https://github.com/akkartik/mu/blob/master/079write-int.subx
1
2
3 == code
4
5 write-int:
6
7 55/push-ebp
8 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
9
10 50/push-eax
11 51/push-ecx
12 57/push-edi
13
14 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
15
16 8b/copy 0/mod/indirect 7/rm32/edi . . . 1/r32/ecx . .
17
18 3b/compare 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 8/disp8 .
19 7d/jump-if-greater-or-equal $write-int:abort/disp8
20 $write-int:to-stream:
21
22 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0xc/disp8 .
23 89/copy 1/mod/*+disp8 4/rm32/sib 7/base/edi 1/index/ecx . 0/r32/eax 0xc/disp8 .
24
25 81 0/subop/add 0/mod/indirect 7/rm32/edi . . . . . 4/imm32
26 $write-int:end:
27
28 5f/pop-to-edi
29 59/pop-to-ecx
30 58/pop-to-eax
31
32 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
33 5d/pop-to-ebp
34 c3/return
35
36 $write-int:abort:
37
38
39 68/push "write-int: out of space\n"/imm32
40 68/push 2/imm32/stderr
41
42 e8/call _write/disp32
43
44 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
45
46 bb/copy-to-ebx 1/imm32
47 b8/copy-to-eax 1/imm32/exit
48 cd/syscall 0x80/imm8
49
50
51 test-write-int-single:
52
53
54
55
56 68/push _test-stream/imm32
57
58 e8/call clear-stream/disp32
59
60 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
61
62
63 68/push 0x64636261/imm32
64 68/push _test-stream/imm32
65
66 e8/call write-int/disp32
67
68 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
69
70
71 68/push "F - test-write-int-single"/imm32
72 68/push "abcd"/imm32
73 68/push _test-stream/imm32
74
75 e8/call check-stream-equal/disp32
76
77 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
78
79 c3/return
80
81 test-write-byte-buffered-multiple:
82
83
84
85
86 68/push _test-stream/imm32
87
88 e8/call clear-stream/disp32
89
90 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
91
92
93 68/push 0x64636261/imm32
94 68/push _test-stream/imm32
95
96 e8/call write-int/disp32
97
98 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
99
100
101 68/push 0x68676665/imm32
102 68/push _test-stream/imm32
103
104 e8/call write-int/disp32
105
106 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
107
108
109 68/push "F - test-write-byte-buffered-multiple"/imm32
110 68/push "abcdefgh"/imm32
111 68/push _test-stream/imm32
112
113 e8/call check-stream-equal/disp32
114
115 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
116
117 c3/return
118
119