I am currently playing around with pointer and indirect addressing on the C64 and I encountered a problem with the ADC opcode.
I am trying to increment a number repeatedly and when it overflows (goes over #$FF/255) it should increments another value by one.
But instead of setting the overflow flag after #$FF (255), the CPU sets it after #$7F (127).
After a bit of research I noticed that the ADC opcode seems to be working with signed bytes and therefore sets the C and V flags when it goes over #$7F.
Is there a way to make an unsigned addition on the 6502 by setting or clearing some flags before doing an addition or is there a trick to circumvent it ?
Here is the code I used:
PRT_LOW = $FD PTR_HIGH = $FE * = $1000 start lda #$28 ; Load value, add with carry and store the result adc PTR_LOW sta PRT_LOW bvc end ; Branch on overflow clear, the V flag is set if A >= #$80 ; instead of a "regular" overflow (more than #$FF) inc PTR_HIGH ; Increase the "higher address value" end ;[Unrelated code...] jmp start