How Jump instruction is executed based on value of Out- The Alu Output

本秂侑毒 提交于 2019-12-02 04:31:46

If out < 0, the jump is executed if j1 = 1.

If out = 0, the jump is executed if j2 = 1.

If out > 0, the jump is executed if j3 = 1.

Hopefully now you can understand the table better. In particular, JNE is executed if out is non-zero, and is skipped if out is zero.

The mnemonic makes sense if those are match-any conditions, not match-all. i.e. jump if the difference is greater or less than zero, but not if it is zero.

Specifically, sub x, y / jne target works the usual way: it jumps if x and y were equal before the subtraction. (So the subtraction result is zero). This is what the if(out!=0) jump in the Effect column is talking about.

IDK the syntax for Nand2Tetris, but hopefully the idea is clear.


BTW, on x86 JNZ is a synonym for JNE, so you can use whichever one is semantically relevant. JNE only really makes sense after something that works as a compare, even though most operations set ZF based on whether the result is zero or not.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!