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