I can't get the array values printed.
The program does not display any errors until it reaches the "printloop:" label. There is some error that makes it impossible to print the values, but I cannot find it.
I hope you can.
; compile: nasm -felf64 array.asm
; linked in Ubuntu/Linux Mint: gcc -no-pie array.o -o array
; run: ./array
segment .data
lst: dq 101, 102, 103, 104, 105
len: equ (($ - lst) / 8)
fmt: dq "%lld ",10, 0
segment .text
global main
extern printf
main:
mov ecx, len
lea rbx, [lst]
mov rdx, rbx ; We'll use RDX below.
xor edi,edi
xor eax,eax
pushloop:
push qword [rbx+rdi*8]
add rdi,1
dec ecx
jnz pushloop
mov ecx, len
xor edi, edi
poploop:
pop rax
mov [rdx+rdi*8], rax
add rdi,1
dec ecx
jnz poploop
mov ecx, len
xor edi, edi
printloop:
mov rax, [rdx+rdi*8]
add rdi, 1
mov rcx, fmt
mov rsi, rax
call printf wrt ..plt
dec ecx
jnz printloop
end:
mov eax, 60
xor edi,edi
syscall
Thany you in advance.