Meterman58761 wrote:
The instructions I'm interested in at the moment are TST, BGT, BLE, BLT.
If you are testing a memory location, take a close look at the 6502 BIT instruction. Like the 6800 BIT, it ANDs register A with the memory location to determine the Z flag. But it also determines the N and V flags based solely on the upper two bits of the memory location (unaffected by the contents of register A) making for a very efficient way to implement a couple of flags within a memory location. I wish the 680x had something similar.
You can somewhat make up for the loss of accumulator B by moving values into registers X or Y. There are a few times when the two not-quite-accumulators X and Y are better than the second full-accumulator B.
BGT, BLE and BLT are for signed comparisons. You cannot use CMP for the test because it does not affect the V flag. You must use the combination of SEC followed by SBC.
Speaking of, the 6502 does not have add without carry or subtract without borrow; be careful to do CLC before ADC and SEC before SBC if you do not want a carry or borrow involved.
If your assembler provides BLO as an alias for BCC and BHS for BCS, use them where appropriate to make your code more obvious. For example,
Code:
cmp #'0'
blo NotNumeric
instead of
Code:
cmp #'0'
bcc NotNumeric
If your assembler does not, create a macro to do that if your assembler supports them.
Finally, it is easy to be spoiled by the variety of conditional branches on the 680x. Even the 68000 comes up short.
If your 680x code does this:
Code:
cmpa #'9'
bhi NotNumeric
do this on the 6502:
Code:
cmp #'9'+1
bhs NotNumeric