https://github.com/akkartik/mu/blob/master/102kernel-string.subx
1
2
3
4
5 == code
6
7 kernel-string-to-string:
8
9 55/push-ebp
10 89/<- %ebp 4/r32/esp
11
12 51/push-ecx
13 52/push-edx
14 53/push-ebx
15 56/push-esi
16 57/push-edi
17
18 (kernel-string-length *(ebp+0xc))
19 89/<- %ecx 0/r32/eax
20
21 (allocate-array *(ebp+8) %ecx)
22
23 ba/copy-to-edx 0/imm32
24
25 8b/-> *(ebp+0xc) 6/r32/esi
26
27 8d/copy-address *(eax+4) 7/r32/edi
28 {
29 $kernel-string-to-string:loop:
30
31 8a/byte-> *esi 2/r32/edx
32
33 81 7/subop/compare %edx 0/imm32
34 74/jump-if-= break/disp8
35
36 88/byte<- *edi 2/r32/edx
37
38 46/increment-esi
39
40 47/increment-edi
41 eb/jump loop/disp8
42 }
43 $kernel-string-to-string:end:
44
45 5f/pop-to-edi
46 5e/pop-to-esi
47 5b/pop-to-ebx
48 5a/pop-to-edx
49 59/pop-to-ecx
50
51 89/<- %esp 5/r32/ebp
52 5d/pop-to-ebp
53 c3/return
54
55 kernel-string-length:
56
57 55/push-ebp
58 89/<- %ebp 4/r32/esp
59
60 51/push-ecx
61 52/push-edx
62
63 b8/copy-to-eax 0/imm32
64
65 b9/copy-to-ecx 0/imm32
66
67 8b/-> *(ebp+8) 2/r32/edx
68 {
69 $kernel-string-length:loop:
70
71 8a/byte-> *edx 1/r32/ecx
72
73 81 7/subop/compare %ecx 0/imm32
74 74/jump-if-= break/disp8
75
76 42/increment-edx
77
78 40/increment-eax
79
80 eb/jump loop/disp8
81 }
82 $kernel-string-length:end:
83
84 5a/pop-to-edx
85 59/pop-to-ecx
86
87 89/<- %esp 5/r32/ebp
88 5d/pop-to-ebp
89 c3/return