Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 比较'+';签名程序集x86_Assembly_X86 - Fatal编程技术网

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 '+'