;I am trying to print the elements of an array on console in nasm ,but it is always printing only last two elements ,why is that: this is my code:
section .data
msg db 1,2,3
msg_len equ ($ - msg)
separator db ' ' ; Separator character
separator_len equ $ - separator
temp db 0
section .text
global _start
_start:
mov rbx,msg_len
mov rsi,0
again:
xor rax,rax
mov al, [msg + rsi]
add al,'0'
mov [temp],al
xor al,al
; Print the character
mov rdi, 1 ; File descriptor (stdout)
mov rdx, 1 ; Length of the string to print
mov rcx,temp
mov rax, 4 ; System call number for write
int 0x80 ; Call the kernel
inc rsi
; Print the separator
mov rdi, 1 ; File descriptor (stdout)
mov rdx, separator_len ; Length of the separator
mov rcx, separator ; Separator to print
mov rax, 4 ; System call number for write
int 0x80 ; Call the kernel
dec rbx
cmp rbx,0
jne again
mov rax, 1 ; System call number for exit
xor rbx, rbx ; Exit code 0
int 0x80 ; Call the kernel
i want to print the elements of array but it is always printing only last two elements