https://github.com/akkartik/mu/blob/master/subx/053new-segment.subx
1
2
3 == code
4
5
6
7
8
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 00 00 00 00
52
53 00 00 00 00
54
55 03 00 00 00
56
57 22 00 00 00
58
59 ff ff ff ff
60
61 00 00 00 00
62
63