I want to iterate over the characters of a string and convert every single character to its respective ASCII value. So far I have created this program that takes input from the user and then stores it in the buffer
. I have also created a loop that reads the character from the buffer (esi
) and stores it within the al
register. After supposedly converting the character in al
to ASCII, it increments esi
to go to the next character and runs the loop_start
routine again.
section .data
prompt db "Enter your message: "
prompt_len equ $-prompt
newline db 10, 0
section .bss
buffer resb 255
section .text
_start:
mov eax, 4
mov ebx, 1
mov ecx, prompt
mov edx, prompt_len
int 0x80
mov eax, 3
mov ebx, 2
mov ecx, buffer
mov edx, 255
int 0x80
mov esi, buffer
loop_start:
mov al, byte [esi]
cmp al, 0
je done
cmp esi, buffer
je print_char
print_char:
; do something
inc esi
jmp loop_start
done:
mov eax, 1
mov ebx, 0
int 0x80
ret
How do I make it so that I am able to print out the ASCII value of the character as the loop iterates over it. Thank you in advance!