我正在为装配制作 atoi 功能。
无论我尝试什么都行不通,我也不知道为什么。
有谁知道是什么问题?
org 100h
mov si, stri ;parameter
call atoi ;call function
pop eax ;result
mov [broj], eax ;save
mov ah, 9 ;display (in ascii, because I don't have itoa function yet either)
mov dx, broj
int 21h
mov ah, 8
int 21h
int 20h
atoi:
mov eax, 0 ;stores result
mov ebx, 0 ;stores character
atoi_start:
mov bl, [si] ;get character
cmp bl, '$' ;till dollar sign
je end_atoi
imul eax, 10 ;multiplu by 10
sub bl, 30h ;ascii to int
add eax, ebx ;and add the new digit
inc si ;;next char
jmp atoi_start
end_atoi:
push eax ;return value
ret
stri db '1000$'
broj: db ?,?, '$'