I'm new to 6502 Assembly and hexadecimal in general, so I'm really confused about how arithmetics work.
For example:
LDA #$c0
TAX
INX
ADC #$c4
BRK
c0 + c4
is too big for a byte, implying that it's 192 + 196
. Thus setting the carry flag and resulting in the hex value 84
.
But on the other hand, doing only LDA #$c0
sets the negative flag, implying that c0
isn't actually 92
but -64
. So the operation becomes -64 + -60
. That result is -124
. That would "fit" as it's still the hex value 84
.
I just can't wrap my head around it. Does 6502 Assembly use 0
to 255
for hex values or -127
to 127
? Why does the code above set the carry flag?