相等从堆栈中弹出两个顶部值并进行比较。
如果它们相等,则推送值-1(十六进制中的FFFF)。
否则推送0。在条件语句中,FFFF代表真,0代表假。示例
之前 之后
堆栈 堆栈
7 0
8
结果如下:
代码
POP_D
POP_A
D = D - A
A = NOT_EQ_0
D; JNE
D = -1
A = END_BY_PUSH_RESULT
JMP
NOT_EQ_0:
D = 0
END_BY_PUSH_RESULT:
PUSH_D
其它几个类似:
需要注意的是,
说明中两个值可能是反的
右边有test工具,可以初始化stack,push值到stack
且可以看到栈顶的addr变化(存储在addr 0的ram中)
POP_D
POP_A
D = D - A
A = NOT_GT
D; JGE
D = -1
A = END_BY_PUSH_RESULT
JMP
NOT_GT:
D = 0
END_BY_PUSH_RESULT:
PUSH_D
LT同理如下:
POP_D
POP_A
D = D - A
A = NOT_LT
D; JLE
D = -1
A = END_BY_PUSH_RESULT
JMP
NOT_LT:
D = 0
END_BY_PUSH_RESULT:
PUSH_D
NOT
POP_D
D = ~D
PUSH_D
GOTO
A = label
JMP
IF_GOTO
POP_D
A = label
D; JNE