Assembly 比较'+';签名程序集x86
我试图将命令行中的参数与“+”进行比较。如果相等,则应转到“添加:标签”。我得到了三个参数,两个数字和符号,我想比较一下。不幸的是,它不起作用 我的代码:Assembly 比较'+';签名程序集x86,assembly,x86,Assembly,X86,我试图将命令行中的参数与“+”进行比较。如果相等,则应转到“添加:标签”。我得到了三个参数,两个数字和符号,我想比较一下。不幸的是,它不起作用 我的代码: 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 ad
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
这里要做的是将一个字符(通常是一个单字节)与作为第三个参数的字符串的32位地址进行比较。这显然是不匹配的
适当的比较是:
mov esi,[eax+12] //third argument
cmp byte [esi],'+' ; compare the first character of the third argument with '+'
感谢您的回复,但控制台显示:错误:“cmp”的操作数大小不明确,当我尝试编译时,我认为您使用的是NASM。如果这是英特尔语法的GAS,您可能应该使用
byte ptr
而不是byte
。最好使用jne end
跳过add:
块,而不是使用条件跳转跳过无条件跳转。
mov esi,[eax+12] //third argument
cmp byte [esi],'+' ; compare the first character of the third argument with '+'