https://github.com/akkartik/mu/blob/master/subx/053new-segment.subx
1
2
3 == code
4
5
6
7
8 Entry:
9
10
11 68/push 0x1000/imm32
12
13 e8/call new-segment/disp32
14
15 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
16
17
18 c7 0/subop/copy 0/mod/direct 0/rm32/EAX . . . . . 0x34/imm32
19
20
21 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
22 b8/copy-to-EAX 1/imm32/exit
23 cd/syscall 0x80/imm8
24
25 new-segment:
26
27 55/push-EBP
28 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
29 53/push-EBX
30
31
32 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 0/r32/EAX 8/disp8 .
33 bb/copy-to-EBX _mmap-new-segment/imm32
34 89/copy 1/mod/*+disp8 3/rm32/EBX . . . 0/r32/EAX 4/disp8 .
35
36 bb/copy-to-EBX _mmap-new-segment/imm32
37 b8/copy-to-EAX 0x5a/imm32/mmap
38 cd/syscall 0x80/imm8
39 $new-segment:end:
40
41 5b/pop-to-EBX
42 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
43 5d/pop-to-EBP
44 c3/return
45
46 == data
47
48
49 _mmap-new-segment:
50
51 0/imm32
52
53 0/imm32
54
55 3/imm32
56
57 0x22/imm32
58
59 -1/imm32
60
61 0/imm32
62
63