Page 1 of 1
indexed addressing modes - signed?
Posted: Sat Sep 20, 2008 7:45 pm
by raejae
Hello all,
I'm looking for a piece of information that I can't seem to find anywhere, therefore must be blatantly obvious and I'm missing it.
When using indexed addressing modes, is the index interpreted as signed or unsigned? (ie if I have the address $2000 and the index in the X register is $80, will the affected address be $2080 or $1F80?
Documentation specifically mentions the offset in the relative addressing mode as being signed, but says nothing about the index in an indexed mode.
Thanks,
-Nick
Posted: Sat Sep 20, 2008 8:17 pm
by 8BIT
for 6502 and 65C02 architecture
The absolute indexed address modes are unsigned.
$2000, x where x is $90 = $2090
$20F0, x where x = $90 = $2180
The zero page indexed modes are also unsigned, but will be truncated into zero page even if the sum exceeds $FF.
$F0, x where x is $20 = $10 ($F0+$20=$110, then AND with $0FF for result)
Zero page indirect indexed will also be unsigned and truncated to zero page for the pointer value.
Daryl
Posted: Sat Sep 20, 2008 8:53 pm
by kc5tja
Zero page indirect indexed will also be unsigned and truncated to zero page for the pointer value.
This definitely is true for the 6502.
However, the 65816 in native-mode behaves differently, if memory serves me correctly. Since direct-page can now float freely anywhere in bank 0, I believe that if X=$F0 and you access $F0,X, you will actually access location (D+$1E0) & 0xFFFF, where D is the current address stored in the direct page register.
So, for the benefit of folks reading this forum, particularly those new to the "Terbium" architecture, it would be most helpful to qualify which CPUs you're asking about.
Posted: Sat Sep 20, 2008 9:51 pm
by raejae
That's exactly what I needed--thanks!
Posted: Sat Sep 20, 2008 11:00 pm
by 8BIT
So, for the benefit of folks reading this forum, particularly those new to the "Terbium" architecture, it would be most helpful to qualify which CPUs you're asking about.
My original response has been corrected.
you can fake it
Posted: Sun Sep 21, 2008 10:42 pm
by bogax
Perhaps it's obvious (although, I didn't think of it) but it may be worth
noting that since subtaction is just addition you can negate your
base/index and structure your table accordingly to achieve a
similar result, as is done in the fast quarter-square multiply.
(attributed to George Taylor)
Posted: Sun Sep 21, 2008 11:53 pm
by kc5tja
The other method that I've used in the past is called "bias-128." What this means is that I map zero to $80, one to $81, and negative one to $7F. You'll sometimes see this in DACs, for example.