I was perusing the various news items, and found a nice tutorial on CMP, CPX, and CPY. I also found a nasty bug. The code as presented, in the very last tutorial, is as follows:
Code:
LDX #00 ;Index = 0
NXTBYT LDA $20,X ;Load next byte
STA $0320,X ;Store next byte
INX ;Increment index
CPX $1F ;All bytes moved?
BNE NXTBYT ;If not, move next byte
Oh, it'll make good on the tutorial's promise of moving up to 256 bytes of data. However, it'll move it from zero page on the 6502, and part of direct page and into the stack on the 65816. This code, therefore, is not portable, and is quite likely not what the author intended.
I think the intention of the code, as I understand it, is best expressed with the following code:
Code:
LDY #00 ;Index = 0
NXTBYT LDA ($20),Y ;Load next byte
STA $0320,Y ;Store next byte
INY ;Increment index
CPY $1F ;All bytes moved?
BNE NXTBYT ;If not, move next byte
This way, we set up a pointer to the data to be moved at location $20, so that if the user really does want to move from zero page and part of the stack space, then he can do so. Besides, it gives the Y register some of the limelight that X always seems to get.
On the other hand, it's also 1:18 AM for me here, so maybe I'm just getting too sleepy...