GARTHWILSON wrote:
I have never used them either. It would be nice if they were there with an absolute (instead of ZP) addressing mode, to make them useful for I/O. I guess they were in ZP because a few microcontrollers had I/O there and they had so little ROM that it was important to save one byte each time one of these instructions was encountered; but that's not normal for our applications. The '816 of course has so many additional instructions and addressing modes that are more important, that keeping BBS & friends would have required using the WDM op code extension and making them 5-byte instructions taking probably 8 clocks. I probably should be always bank 0 (regardless of the data bank register) as that's where I/O would normally be.
TRB and TSB are very useful in I/O work,as they may be used on hardware registers to turn off or turn on features (but not on the NXP 2691, 2692 or 2698!). In the 65C816, TRB and TSB can process 16 bit values, making them extra useful in filesystem structure manipulations. For example, in UNIX-like filesystems, file characteristics are encoded into a 16 bit value, of which nine bits specify read, write and execute permissions for owner, group and others. Real easy to diddle with the '816 in 16 bit accumulator and memory mode and a 16 bit mask in the accumulator.
One of my reasons for ignoring BBR and BBS, other than their limitation to ZP addressing, is that the bit being tested is hard-coded into the instruction, making it a hassle to write a routine that can change which bit it's testing on the fly. Also, I mostly use bits 6 and 7 (or 14 and 15 if the
m bit in the 65C816's status register is cleared) for flag purposes, which are easily tested with a BIT instruction. Or BIT immediate can be used...plus TRB and TSB can readily clear or set those bits. There's lots of bit-twiddling flexibility without the BBR and BBS instructions being present.