如果不相等则跳跃即使在相等时仍然跳跃

-4 assembly winapi

include 'win32ax.inc'
.code
start:
mov bx, 60
mov ax, 60
cmp ax, bx
jne inv
inv:
invoke MessageBoxA, NULL, "Hello!", "Notice:", NULL, MB_OK
invoke ExitProcess, 0
.end start  
Run Code Online (Sandbox Code Playgroud)

BX和AX都有60,所以它为什么跳到标签并打电话给消息框?它正在这样做.

Jose的工作解决方案:

include 'win32ax.inc'
.code
start:
mov bx, 60
mov ax, 60
cmp ax, bx
jne inv
jmp THEY_ARE_EQUAL
inv:
invoke MessageBoxA, NULL, "Hello!", "Notice:", NULL, MB_OK
invoke ExitProcess, 0

THEY_ARE_EQUAL:
invoke ExitProcess, 0
.end start  
Run Code Online (Sandbox Code Playgroud)

小智 6

他告诉你使用更简单的方法.移动标签超过MessageBoxA调用,并将分支类型更改为其反向,je:

include 'win32ax.inc'
.code
start:
mov bx, 60
mov ax, 60
cmp ax, bx
je skip
invoke MessageBoxA, NULL, "Hello!", "Notice:", NULL, MB_OK
skip:
invoke ExitProcess, 0
.end start
Run Code Online (Sandbox Code Playgroud)

并且由于您使用任一方式的代码0调用ExitProcess,您可以省略冗余调用并让MessageBoxA的调用通过跳过标签直接进入ExitProcess调用.