<<< Jumps Based on Bit Settings | Index | Conditional Jump Limitation and Workaround >>> |
A program can test register for zero value by OR instruction:
or bx, bx ; Is BX = 0? jz is_zero ; Jump if so
This code is functionally equivalent to:
cmp bx, 0 ; Is BX = 0? je is_zero ; Jump if so
but produces smaller and faster code, since it does not use an immediate number as an operand. The same technique also lets you test a registers sign bit:
or dx, dx ; Is DX sign bit set? js sign_set ; Jump if so
Note that none of the above OR instructions change original value in the register.
<<< Jumps Based on Bit Settings | Index | Conditional Jump Limitation and Workaround >>> |