我正在尝试将命令行中的参数与“+”进行比较。如果相等就应该去添加:label。我得到三个参数,2 个数字和符号,我想对其进行比较。不幸的是,它的比较不起作用。
我的代码:
main:
mov eax,[esp+8]
mov ecx,[eax+4] //first argument
mov ebx,[eax+8] //second argument
mov esi,[eax+12] //third argument
mov eax,esi
cmp eax,'+'
je add
jmp end
add:
//rest of code
最佳答案
mov esi,[eax+12] //third argument
mov eax,esi
cmp eax,'+'
您在这里所做的是将字符(通常是单个字节)与作为第三个参数的字符串的 32 位地址进行比较。这显然不匹配。
适当的比较是:
mov esi,[eax+12] //third argument
cmp byte [esi],'+' ; compare the first character of the third argument with '+'
关于assembly - 比较 '+' 符号程序集 x86,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34716817/