-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.asm
105 lines (91 loc) · 1.22 KB
/
index.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
section .bss
vec: resb 4
v: resb 4
v0: resb 4
v1: resb 4
ap: resb 4
section .text
extern println
extern printstr
extern push_back
extern set
extern retr
extern alloc
extern malloc
global _start
_start:
call main
mov eax, 1
int 0x80
main:
mov eax, RPP_CONSTANT_0
push eax
mov eax, 2
push eax
call printstr
mov eax, 2
mov [vec], eax
lea eax, vec
mov [v], eax
mov eax, [v]
push eax
mov eax, RPP_CONSTANT_1
push eax
call push_back
mov eax, [v]
push eax
mov eax, 0
push eax
call retr
mov eax, eax
mov [v0], eax
mov eax, [v0]
push eax
mov eax, 2
push eax
call printstr
mov eax, [v]
push eax
mov eax, RPP_CONSTANT_2
push eax
call push_back
mov eax, [v]
push eax
mov eax, 1
push eax
call retr
mov eax, eax
mov [v1], eax
mov eax, [v1]
push eax
mov eax, 2
push eax
call printstr
mov eax, 4
push eax
call alloc
mov eax, eax
mov [ap], eax
mov eax, [ap]
push eax
mov eax, RPP_CONSTANT_3
push eax
call malloc
mov ebx, [ap]
mov eax, [ebx]
mov eax, eax
push eax
mov eax, 2
push eax
call printstr
%define aa ap
mov eax, 4
mov [aa], eax
mov eax, 0
ret
section .data
NEWLINE db 10
RPP_CONSTANT_0 db "hi", 0
RPP_CONSTANT_1 db "ch", 0
RPP_CONSTANT_2 db "sh", 0
RPP_CONSTANT_3 db "hi", 0