Z-flag and JMP
ags
Posts: 386
The manual is not clear to me on when the Z-flag is set by the JMP PASM instruction. The opcode table shows "Result=0" - but what does that mean for JMP? The destination field is unused (it's not specified at all for JMP), and the destination is not written unless WR is specified. So what is result value that must be =0 for the Z-flag to be set?
Comments
See also the Similar Threads box below.
And what about the carry flag if you specify WC ?
Might be a useful trick to tighten up code.
Bean
Unsigned borrow (dst ? src).
So it looks to me that the carry would always be set if WC was used since value1 would be zero and value2 would be non-zero (zero < non-zero).
And that the zero flag would always be cleared if WZ was used since "pc" would be non-zero (zero | pc != 0).
Bean
The carry depends on the value located at the address given by the destination field, and the value given by the source field. For a jmp instruction compiled by the Spin Tool, the destination address is 0, but the contents of location 0 may contain a non-zero value. The source field could specify either a 9-bit immediate value, or it could be the address for a 32-bit value. The C flag comparison is done on 32-bit values.
So if you really wanted to be tricky you could perform a jmp and compare two 23-bit values at the same time. The 23-bit values would be stored in the most significant bits of the locations addressed by the source and destination fields. The jump target address would be stored in the 9 least significant bits of the location addressed by the source field. The 9 LSBs of the value addressed by the destination field would have to match the 9 LSBs located at the source address, or you could bias the comparison by making the 9 LSBs all zeros or all ones.
Out of curiosity, what value does the PASM assembler place in the dst section of the instruction? I presume it's all $00 (not that it matters)
@Dave Hein: not to nitpick, instead to make sure I'm clear on this - did you mean to say "The zero bit is determined by the result, which consist of the 23 most significant bits of the destination value or'ed with the 9-bit value of the next address in the program counter"?