https://github.com/akkartik/mu/blob/master/310copy-bytes.subx
1
2
3 == code
4
5 copy-bytes:
6
7
8
9
10
11
12
13
14
15
16
17
18 55/push-ebp
19 89/<- %ebp 4/r32/esp
20
21 50/push-eax
22 51/push-ecx
23 52/push-edx
24 56/push-esi
25 57/push-edi
26
27 8b/-> *(ebp+8) 6/r32/esi
28
29 8b/-> *(ebp+0xc) 7/r32/edi
30
31 b9/copy-to-ecx 0/imm32
32
33 8b/-> *(ebp+0x10) 2/r32/edx
34 {
35
36 39/compare %ecx 2/r32/edx
37 7d/jump-if->= break/disp8
38
39 8a/byte-> *esi 0/r32/AL
40 88/byte<- *edi 0/r32/AL
41
42 46/increment-esi
43 47/increment-edi
44 41/increment-ecx
45 eb/jump loop/disp8
46 }
47 $copy-bytes:end:
48
49 5f/pop-to-edi
50 5e/pop-to-esi
51 5a/pop-to-edx
52 59/pop-to-ecx
53 58/pop-to-eax
54
55 89/<- %esp 5/r32/ebp
56 5d/pop-to-ebp
57 c3/return
58
59 stream-to-string:
60
61 55/push-ebp
62 89/<- %ebp 4/r32/esp
63
64 50/push-eax
65 51/push-ecx
66 52/push-edx
67 56/push-esi
68
69 8b/-> *(ebp+8) 6/r32/esi
70
71 8b/-> *esi 1/r32/ecx
72 2b/subtract *(esi+4) 1/r32/ecx
73
74 (allocate-array Heap %ecx *(ebp+0xc))
75
76 8b/-> *(esi+4) 2/r32/edx
77 8d/copy-address *(esi+edx+0xc) 2/r32/edx
78
79 8b/-> *(ebp+0xc) 0/r32/eax
80 (lookup *eax *(eax+4))
81 8d/copy-address *(eax+4) 0/r32/eax
82
83 (copy-bytes %edx %eax %ecx)
84 $stream-to-string:end:
85
86 5e/pop-to-esi
87 5a/pop-to-edx
88 59/pop-to-ecx
89 58/pop-to-eax
90
91 89/<- %esp 5/r32/ebp
92 5d/pop-to-ebp
93 c3/return
94
95 test-stream-to-string:
96
97 55/push-ebp
98 89/<- %ebp 4/r32/esp
99
100 (clear-stream _test-input-stream)
101 (write _test-input-stream "abc")
102
103 (read-byte _test-input-stream)
104
105 68/push 0/imm32
106 68/push 0/imm32
107 89/<- %ecx 4/r32/esp
108
109 (stream-to-string _test-input-stream %ecx)
110 (lookup *ecx *(ecx+4))
111 (check-strings-equal %eax "bc")
112
113 89/<- %esp 5/r32/ebp
114 5d/pop-to-ebp
115 c3/return