-
Notifications
You must be signed in to change notification settings - Fork 3
/
arrayTest.asm
169 lines (137 loc) · 2.52 KB
/
arrayTest.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
section .bss
array: resb 20
size: resb 4
index: resb 4
sizes: resb 4
i: resb 4
section .text
global _start
push_back:
pop edi
pop eax
pop edx
mov ebx, [edx]
mov [edx + 4*(ebx)], eax
push edi
ret
log:
pop edi
; pop edx
pop ecx
mov edx, [sizes + (ecx+1)*4]
mov ecx, [array + (ecx+1)*4]
mov ebx, 1
mov eax, 4
int 0x80
push edi
ret
set:
pop edi
pop eax
pop edx
pop esi
mov [eax + (edx+1)*4], esi
push edi
ret
_start:
mov WORD [index], 0
mov eax, 5
mov [array + 0*4], eax
mov eax, y
mov [array + 1*4], eax
mov eax, y
mov [array + 2*4], eax
mov eax, msg
mov [array + 3*4], eax
mov eax, msg2
mov [array + 4*4], eax
mov eax, 1
mov [sizes + 0*4], eax
mov eax, 1
mov [sizes + 1*4], eax
mov eax, 1
mov [sizes + 2*4], eax
mov eax, 15
mov [sizes + 3*4], eax
mov eax, 13
mov [sizes + 4*4], eax
mov eax, 15
mov [sizes + 5*4], eax
mov eax, array
push eax
mov eax, msg
push eax
call push_back
mov eax, x
push eax
mov eax, 0
push eax
mov eax, array
push eax
call set
re:
mov eax, [index]
push eax
call log
mov eax, 1
add [index], eax
mov ecx, NEWLINE
mov edx, 1
mov ebx, 1
mov eax, 4
int 0x80
mov eax, [array]
sub eax, 1
sub eax, [index]
jnz re
mov eax, 1
int 0x80
; mov eax, [index]
; mov eax, [array + eax*4]
; mov ecx, eax
; mov edx, 1
; mov ebx, 1
; mov eax, 4
; int 0x80
; mov eax, 1
; add [index], eax
; mov ecx, NEWLINE
; mov edx, 1
; mov ebx, 1
; mov eax, 4
; int 0x80
; mov eax, [index]
; mov eax, [array + eax*4]
; mov ecx, eax
; mov edx, 1
; mov ebx, 1
; mov eax, 4
; int 0x80
; mov eax, 1
; add [index], eax
; mov ecx, NEWLINE
; mov edx, 1
; mov ebx, 1
; mov eax, 4
; int 0x80
; mov eax, [index]
; mov eax, [array + eax*4]
; mov ecx, eax
; mov edx, 8
; mov ebx, 1
; mov eax, 4
; int 0x80
; mov ecx, NEWLINE
; mov edx, 1
; mov ebx, 1
; mov eax, 4
; int 0x80
section .data
x db '5'
y db '3'
msg db "pointer arrays!"
msg2 db "arrays r cool"
len equ $ - msg
NEWLINE db 10
segment .bss
sum resb 1