So I have been trying to print digits in x64 assembly nasm program and my source code is this:
section .data digit: db 0, 10 section .text global _start _start: mov rax, 6 mov rbx, 2 div rbx call _printRAXDigit mov rax, 60 mov rdi, 0 syscall _printRAXDigit: add rax, 48 mov [digit], al mov rax, 1 mov rdi, 1 mov rsi, digit mov rdi, 2 syscall ret But the output is empty and nothing appears. Is there a problem with my code or assembler
UPDATE: CherryDT found the answer it was that I typed rdi instead rdx
rdia second time instead ofrdx(so you wrote an undefined number of characters depending on previous contents ofrdx- probably zero - tostderr, i.e. FD 2, instead of printing 2 characters tostdout). I recommend learning how to use a debugger, you could then easily observe that this is happening if you break on thesyscalland check the registers.strace ./a.outto see what args you pass to system calls. e.g. that you passed length = 0 (the remainder fromdiv, which didn't fault since this is presumably built into a static executable so RDX was zero before the division as well). Basic debugging would have caught this typo, closing as a duplicate mostly as a typo.