Iam learning assembly and I found out how to get user input with
mov al, 3 ; system call number (sys_read)
xor bl, bl ; file descriptor 0 (stdin)
mov rcx, buf ; buffer to store input
mov dl, 4 ; Lenght of buffer
int 0x80 ; interrupt
but that actually gets a string right?
my question is how do i get a integer value…
so if i type 100 how do i get the value 64h so i can add, subtract etc
instead of a string with each byte being the ascii representation of the number
and then how do i output a value like 64h to the screen so that it shows 100?
i dont need code just some guidance
Thanks!
Once you have the ASCII representation, you can just build up the result digit by digit, using the fact that the numerals are encoded in order. In pseudo-code, reading from left to right (i.e. starting with the most significant digit):
resultto 0c,result *= 10; result += (c - '0');resultholds the numeric value of the string