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