Im very new to assembly and nasm and im trying to print all the chars from a string, like this in python:
s = '1234'
for i in s:
print(i)
I have read that only bx register can be used for indexing. But I have seen a lot of people using any other register. But it doesn't work for me in any way.
Im in MacOS x86_64.
SECTION .data
t: db "1234", 10
t.len: equ $-t
e: db "0"
e.len: equ 2
SECTION .text
global start
start:
jmp top
top:
mov al, [rel t + bx]
mov [rel e], al
mov rax, 0x2000004
mov rdi, 1
mov rsi, e
mov rdx, t.len
syscall
inc bx
cmp rsi, 0
je exit
jmp top
exit:
mov rax, 0x2000001
mov rdi, 0
syscall
Im getting this two errors:
get_string_len.asm:20: error: impossible combination of address sizes
get_string_len.asm:20: error: invalid effective address