Hi funkybro, and welcome to the forum.
From the
MOS MCS6500 family programming manual, page 169 of the PDF:
Attachment:
6502_shift.png [ 43.73 KiB | Viewed 2677 times ]
To make it short:
LSR, ROR, ASL, ROL are shifting a Byte (by one Bit position).
Depending on the addressing mode of the instruction,
the Byte either is in the accumulator A,
or in memory (CPU reads the Byte from memory, then shifts it, then writes it back to memory).
;---
Now about what happens with the C flag:
LSR shifts the Byte right, 0 goes into the MSB (Bit 7) of the Byte, the LSB (Bit 0) of the Byte goes into the C flag. //shift right into C flag.
ASL shifts the Byte left, 0 goes into the LSB of the Byte, the MSB of the Byte goes into the C flag. //shift left into C flag.
ROR shifts the Byte right, C flag goes into the MSB of the Byte, the LSB of the Byte goes into the C flag. //rotate right through C flag.
ROL shifts the Byte left, C flag goes into the LSB of the Byte, the MSB of the Byte goes into the C flag. //rotate left through C flag.
;---
Flags N Z are set or cleared according to the result after the shifting:
If the Byte is $00 after the shifting, Z flag is set, else it's cleared. //checking if the result was $00.
A copy of the MSB (Bit 7) of the Byte after the shifting goes into the N flag. //the sign of the result.
;===
So if you do a ROR or a ROL instruction, the interesting question is what was in the C flag before you do it.
Code:
CLC //clear C flag to 0
LDA #$80
STA $1
ROL $1
Would give you $00 as a result.
Flags after the ROL: C=1, Z=1, N=0.
;---
Code:
SEC //set C flag to 1
LDA #$80
STA $1
ROL $1
Would give you $01 as a result.
Flags after the ROL: C=1, Z=0, N=0.
Hope, this helps.