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