https://github.com/akkartik/mu/blob/master/309stream.subx
1
2
3
4 stream-empty?:
5
6 55/push-ebp
7 89/<- %ebp 4/r32/esp
8
9 51/push-ecx
10 56/push-esi
11
12 b8/copy-to-eax 0/imm32/false
13
14 8b/-> *(ebp+8) 6/r32/esi
15
16 8b/-> *esi 1/r32/ecx
17 39/compare-with *(esi+4) 1/r32/ecx
18 0f 9d/set-if->= %al
19 $stream-empty?:end:
20
21 5e/pop-to-esi
22 59/pop-to-ecx
23
24 89/<- %esp 5/r32/ebp
25 5d/pop-to-ebp
26 c3/return
27
28 stream-full?:
29
30 55/push-ebp
31 89/<- %ebp 4/r32/esp
32
33 51/push-ecx
34 56/push-esi
35
36 b8/copy-to-eax 0/imm32/false
37
38 8b/-> *(ebp+8) 6/r32/esi
39
40 8b/-> *(esi+8) 1/r32/ecx
41 39/compare-with *esi 1/r32/ecx
42 0f 9d/set-if->= %al
43 $stream-full?:end:
44
45 5e/pop-to-esi
46 59/pop-to-ecx
47
48 89/<- %esp 5/r32/ebp
49 5d/pop-to-ebp
50 c3/return
51
52 write-to-stream:
53
54 55/push-ebp
55 89/<- %ebp 4/r32/esp
56
57 50/push-eax
58 51/push-ecx
59 52/push-edx
60 53/push-ebx
61 57/push-edi
62
63 8b/-> *(ebp+8) 7/r32/edi
64
65 8b/-> *edi 2/r32/edx
66
67 8b/-> *(ebp+0x10) 1/r32/ecx
68 01/add-to %ecx 2/r32/edx
69 3b/compare 1/r32/ecx *(edi+8)
70 0f 8f/jump-if-> $write-to-stream:abort/disp32
71
72 8d/copy-address *(edi+edx+0xc) 2/r32/edx
73
74 8b/-> *(ebp+0x10) 3/r32/ebx
75 8d/copy-address *(edx+ebx) 3/r32/ebx
76
77 8b/-> *(ebp+0xc) 0/r32/eax
78
79 8b/-> *(ebp+0x10) 1/r32/ecx
80 8d/copy-address *(eax+ecx) 1/r32/ecx
81
82 (_append-4 %edx %ebx %eax %ecx)
83
84 8b/-> *(ebp+0x10) 1/r32/ecx
85 01/add-to *edi 1/r32/ecx
86 $write-to-stream:end:
87
88 5f/pop-to-edi
89 5b/pop-to-ebx
90 5a/pop-to-edx
91 59/pop-to-ecx
92 58/pop-to-eax
93
94 89/<- %esp 5/r32/ebp
95 5d/pop-to-ebp
96 c3/return
97
98 $write-to-stream:abort:
99 (write-buffered Stderr "write-to-stream: stream full\n")
100 (flush Stderr)
101 bb/copy-to-ebx 1/imm32
102 (syscall_exit)
103
104
105 read-from-stream:
106
107 55/push-ebp
108 89/<- %ebp 4/r32/esp
109
110 50/push-eax
111 51/push-ecx
112 52/push-edx
113 53/push-ebx
114 56/push-esi
115
116 8b/-> *(ebp+8) 6/r32/esi
117
118 8b/-> *(esi+4) 2/r32/edx
119
120 8b/-> *(ebp+0x10) 1/r32/ecx
121 01/add-to %ecx 2/r32/edx
122 3b/compare 1/r32/ecx *esi
123 0f 8f/jump-if-> $read-from-stream:abort/disp32
124
125 8d/copy-address *(esi+edx+0xc) 2/r32/edx
126
127 8b/-> *(ebp+0x10) 3/r32/ebx
128 8d/copy-address *(edx+ebx) 3/r32/ebx
129
130 8b/-> *(ebp+0xc) 0/r32/eax
131
132 8b/-> *(ebp+0x10) 1/r32/ecx
133 8d/copy-address *(eax+ecx) 1/r32/ecx
134
135 (_append-4 %eax %ecx %edx %ebx)
136
137 8b/-> *(ebp+0x10) 1/r32/ecx
138 01/add-to *(esi+4) 1/r32/ecx
139 $read-from-stream:end:
140
141 5e/pop-to-esi
142 5b/pop-to-ebx
143 5a/pop-to-edx
144 59/pop-to-ecx
145 58/pop-to-eax
146
147 89/<- %esp 5/r32/ebp
148 5d/pop-to-ebp
149 c3/return
150
151 $read-from-stream:abort:
152 (write-buffered Stderr "read-from-stream: stream empty\n")
153 (flush Stderr)
154 bb/copy-to-ebx 1/imm32
155 (syscall_exit)
156