i'm new programming in ISA x86 64 bits, so i'm trying to print the numbers 1 to 10 in assembly using a conversion in hexadecimal, but I get an infinite loop cause the 8 bit register $cl can't increment. I've been using gdb to analyze the code but I dont find a way to run my code and dont have a infinite loop in the process. I hope y'all can help me, and remember and new into this so bear with me please.
section .data
number db 0; Buffer
nl db 10; \n
section .text
global _start
_start:
; syscall information
mov rax, 1
mov rdi, 1
mov rsi, number
mov rdi, 1
mov byte[number], "0" ; Inicializando the buffer in "0" = 46 Dec
.loop:
add byte[number], cl ; cl contains the data of the number in ASCII format
mov rdx, 1 ; lenght of bytes
syscall
inc cl; ASCII data
cmp cl, 0x39; 0x39 = 57 Dec = 9
jle .loop; lower equal jump
; \n
mov rsi, nl
mov rdx, 1
syscall
; Exit
mov rax, 60
xor rdi, rdi
syscall
I've been using the gdb to analyze the code, even I tried to change the 8 bit register instead of using cl, but nothing works.
syscalldestroysrcxwhich includescl. Pick a different register.raxis used for the return value so that needs to be reloaded as well, although in this case it happens to work. Also, you are always adding tonumberwhich won't do what you want. A possible solution with minimal changes: