1
我知道你可以添加48从十进制转换为ascii或减去48从ASCII转换为十进制,但为什么下面的代码也执行相同的转换?NASM汇编从ASCII转换为十进制
; moving the first number to eax register and second number to ebx
; and subtracting ascii '0' to convert it into a decimal number
mov eax, [number1]
sub eax, '0'
和
; add '0' to to convert the sum from decimal to ASCII
add eax, '0'
你应该谈论数字,而不是数字。 –
只要'eax'中的数字是'0'和'9'之间的一个十进制数字,它就会工作。由于ASCII'0'减去'0'是数字'0',所以ASCII'1'减去'0'是数字'1',依此类推。如果你有更大的数字,你可以将它们按位数进行转换。 – lurker
仅供参考:https://duckduckgo.com/asciitable.html –