[英]What am I comparing to? No CMP instruction in assembly code before JNE
[英]In Assembly, Am I missing something with the cmp command?
因此,我在[ebp-2]和[ebp-4]上都设置了零,并尝试将各个字符转换为它们的真实整数值。 我的问题是当我输入'00'时,程序无法跳转到我指定的标签。
sub byte[ebp-2],30h ; convert characters to integer
sub byte[ebp-4],30h
mov al,10 ;multiply by 10 for the tens value
mul byte[ebp-2]
add ax,[ebp-4] ; add the ones to the computed tens value which is contained in ax
cmp ax,0
je cond_while1
起初,我以为ax可能不会获取值,但是不,ax将获取整数的实值。我通过打印该值对其进行测试。 这是我的测试方式:
mov [ebp+4],ax
add byte[ebp+4],30h ;convert it back to character
mov eax,4 ;print it out
mov ebx,1
lea ecx,[ebp+4]
mov edx,1
int 80h
上面的代码在我输入00时输出0,在我输入01时输出1,这意味着转换值没有问题。 我在cmp命令中缺少什么吗? 我仍在学习汇编语言,所以我不知道我是否错过了一点或有关cmp命令的内容。
当你写
add ax,[ebp-4]
您还可以在[ebp-3]处添加高字节。 这很可能不是空的。 我什至猜测它包含一个0xA值(换行符)...
一个解决方案可能是
movzx bx,[ebp-4]
add ax,bx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.