52 lines
1.5 KiB
Plaintext
52 lines
1.5 KiB
Plaintext
extern _printf
|
|
|
|
section .data
|
|
arr1 dd 3,"a","b","c" ;first dword saves the length
|
|
arr2 dd 3,"A","B","C"
|
|
arr3 dd 3,"1","2","3"
|
|
|
|
section .bss
|
|
arrLocation resd 4
|
|
tempOutput resd 2
|
|
|
|
section .text
|
|
global _main
|
|
_main:
|
|
mov [arrLocation], dword arr1
|
|
mov [arrLocation+4], dword arr2
|
|
mov [arrLocation+8], dword arr3
|
|
mov [arrLocation+12], dword 0 ;signales end
|
|
mov [tempOutput+4], dword 0 ;dword 0 signales end of string
|
|
|
|
mov ecx, 1 ;not 0 as in 0 the length is saved
|
|
looping:
|
|
mov ebx, 0 ;0 as arrLocation doesn't save length
|
|
inloop:
|
|
mov eax, [arrLocation+ebx*4] ;get ebxth arr address
|
|
cmp eax, 0 ;if we don't get an address incresse index
|
|
je incecx
|
|
cmp ecx, [eax] ;when ecx is greater then the length of the current array we end
|
|
jg end
|
|
mov edx, [eax + ecx*4] ;get char at index ecx from arr
|
|
mov [tempOutput], edx ;setup for _printf
|
|
push ecx ;save ecx
|
|
push tempOutput ;parameter for _printf
|
|
call _printf
|
|
add esp, 4 ;garbage collecting
|
|
pop ecx ;restore ecx
|
|
inc ebx ;get next arr
|
|
jmp inloop
|
|
incecx:
|
|
mov [tempOutput], dword 0x0a ;after we print every element at the nth index we print a \n
|
|
push ecx
|
|
push tempOutput
|
|
call _printf
|
|
add esp, 4
|
|
pop ecx
|
|
inc ecx ;increase index
|
|
jmp looping
|
|
|
|
end:
|
|
xor eax, eax
|
|
ret
|