https://github.com/akkartik/mu/blob/master/070new-stream.subx
1
2
3 == code
4
5
6
7
8 new-stream:
9
10 55/push-ebp
11 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
12
13 50/push-eax
14 52/push-edx
15
16
17 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 .
18
19 31/xor 3/mod/direct 2/rm32/edx . . . 2/r32/edx . .
20 f7 4/subop/multiply 1/mod/*+disp8 5/rm32/ebp . . 0xc/disp8 .
21
22 81 7/subop/compare 3/mod/direct 2/rm32/edx . . . . . 0/imm32
23 75/jump-if-!= $new-stream:abort/disp8
24
25 89/copy 3/mod/direct 2/rm32/edx . . . 0/r32/eax . .
26
27 05/add-to-eax 0xc/imm32
28
29
30 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x14/disp8 .
31 50/push-eax
32 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
33
34 e8/call allocate/disp32
35
36 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
37
38 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x14/disp8 .
39 8b/copy 1/mod/*+disp8 0/rm32/eax . . . 0/r32/eax 4/disp8 .
40
41 05/add-to-eax 4/imm32
42
43 89/copy 1/mod/*+disp8 0/rm32/eax . . . 2/r32/edx 8/disp8 .
44
45
46 50/push-eax
47
48 e8/call clear-stream/disp32
49
50 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 4/imm32
51 $new-stream:end:
52
53 5a/pop-to-edx
54 58/pop-to-eax
55
56 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
57 5d/pop-to-ebp
58 c3/return
59
60 $new-stream:abort:
61
62
63 68/push "new-stream: size too large\n"/imm32
64 68/push 2/imm32/stderr
65
66 e8/call _write/disp32
67
68 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
69
70 bb/copy-to-ebx 1/imm32
71 b8/copy-to-eax 1/imm32/exit
72 cd/syscall 0x80/imm8
73
74
75 test-new-stream:
76
77 55/push-ebp
78 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
79
80 68/push 0/imm32/limit
81 68/push 0/imm32/curr
82 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
83
84
85 51/push-ecx
86 68/push 0x200/imm32
87
88 e8/call new-segment/disp32
89
90 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
91
92 8b/copy 0/mod/indirect 1/rm32/ecx . . . 2/r32/edx . .
93
94 68/push 0/imm32
95 68/push 0/imm32
96 89/copy 3/mod/direct 3/rm32/ebx . . . 4/r32/esp . .
97
98
99 53/push-ebx
100 68/push 2/imm32
101 68/push 3/imm32
102 51/push-ecx
103
104 e8/call new-stream/disp32
105
106 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
107
108 8b/copy 1/mod/*+disp8 3/rm32/ebx . . . 0/r32/eax 4/disp8 .
109
110
111 68/push "F - test-new-stream: returns current pointer of allocation descriptor"/imm32
112 52/push-edx
113 50/push-eax
114
115 e8/call check-ints-equal/disp32
116
117 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
118
119 05/add-to-eax 4/imm32
120
121
122 68/push "F - test-new-stream: sets size correctly"/imm32
123 68/push 6/imm32
124 ff 6/subop/push 1/mod/*+disp8 0/rm32/eax . . . . . 8/disp8
125
126 e8/call check-ints-equal/disp32
127
128 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
129
130
131 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
132
133 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
134 5d/pop-to-ebp
135 c3/return
136
137