[Coco] 6809 Q [Mark Mc]
CoCoList for Color Computer Enthusiasts
coco at maltedmedia.com
Thu May 15 12:24:22 EDT 2014
>From Johann Klasek:
On Thu, May 15, 2014 at 11:44:13AM -0400, CoCoList for Color Computer Enthusiasts wrote:
> Well the 6809 is a beast but it does not have this particular addressing
> mode.
>
> You can do this:
>
> LDA [8,Y]
>
> But it's not the same. It will compose the address 8 + Y and the contents
> of this address is loaded into A.
Right, the imaginary addressing mode would be [8],Y ...
The programing paradigma is completly different.
The 6502 zeropage can be regarded as 128 16 bit register array.
For a 6809 style you have to "cache" these registers into
X, Y, U, S
often code snippets consists of
...
STA 8
...
STA 9
...
LDA (8),Y
INY/DEY
or
LDA (8),Y
STA (10),Y
INY/DEY
followed by some condition to check high byte overflow and probably
branch back to complete the loop ...
6809ish:
LDY 08
LDX 10
LDA ,Y+
(STA ,X+)
condition could be
CMPY ...
or
CMPX ...
> > What I'm doing atm is the following:
> >
> > LDY *8
> > LDA B,Y
> >
> > ...and in this case, B is the 8-bit offset. Note that I've also reversed
> > the bytes stored at $8,$9 w.r.t. the 6502.
How is B treated? Like Y above, in a loop or something like a unrolled
loop or structure access a-like?
> > This is used a *LOT* in Lode Runner, so I thought I'd ask if there was a
> > 'better' (shorter) way. [..]
No wonder this is heavy used - this addressing mode is the basic memory
access with a variable address.
I think this is the best for a near 1:1 translation.
In case you want more you have to consider much more of the context
rather then the direct "peephole" translation.
--
Johann Klasek
The dragon on my side: http://klasek.at/hc/dragon/
More information about the Coco
mailing list