I want to transfer string to integer for example, when I type 1234 in string, it will transfer to integer 1234. However, when I type 1234, only 12 comes out as a result and I have no idea what the problem.
%include "asm_io.inc"
segment .bss
string resb 32
segment .text
global main
main:
enter 0,0 ; setup stack frame
pusha
mov edx, 0
mov ecx, 0
mov ebx, 0
repeat: call read_char
sub eax, 48
mov esi, eax
mov eax, ecx
mov ebx, 10
mul ebx
mov ecx, eax
add ecx, esi
mov byte [string+edx], al
cmp al, 0x0a
jne repeat
mov byte [string+edx-1], 0
mov eax, ecx
call print_int
call print_nl
popa
mov eax, 0 ; return value
leave ; leave stack frame
ret
cmp al, 0x0a. You are trying to test for the newline character but you have overwritten AL by effectively subtracting 48 from it. So you are no longer comparing the original value returned byread_char