|
Subject: Re: [stella] I'm looking through 6 digit code From: "Andrew Davie" <atari2600@xxxxxxxxxxxxx> Date: Mon, 19 May 2003 23:08:16 +1000 |
> adc #<zero
> sta ptr0,y
> lda #0
> adc #>zero
> sta ptr0+1,y
The processor is able to shift only 8 bits at a time through its registers.
That is, the X, Y, and A register can only hold 8-bit values. But the
processor can ADDRESS memory locations with a 16-bit range. That is, from 0
to 65535 decimal ( 0 to FFFF Hexadecimal). So if you want to load something
from location $8000 (the $ means hexadecimal), for example, you could do it
directly by lda $8000 - which would work fine, load the contents of
location $8000. But if you wanted to do the load INDIRECTLY, by placing the
address $8000 into a zero page location and then loading from what that
location points to, you will need first to place the 16-bit address into the
two zero page bytes which you use as your indirect pointer.
But, as noted, you can't actually DO that with 8 bit-registers. Not in one
go, anyway. What you'd like to be able to do is go...
lda #$8000
sta ptr0
We can't do that, because $8000 is a 16-bit value. We have to do the load
in two stages. First load/store the high byte of the address, then
load/store the low byte of the address. So...
lda #<$8000
sta ptr0
lda #>$8000
sta ptr0+1
That's just loaded our 16-bit address into a zero page pair of bytes, by
doing it a byte at a time.
Now, instead of using an absolute location address, let's do exactly the
same thing, but using a label instead
lda #<label
sta ptr0
lda #>label
sta ptr0+1
If the address of "label" happened to be $8000, then we would have the same
result. But actually we don't need to know what "label" happens to be - we
let the assembler handle this. As long as "label" is somewhere else in the
code, it will all work OK.
In summary...
lda #<label
the # means load an immediate value (rather than load from the memory
location)
the < means "use the low byte". And > means "use the high byte".
Cheers
A
----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re[2]: [stella] I'm looking through, zu03776 | Thread | [stella] 2003 MiniGame Contest, Memblers |
| Re[2]: [stella] I'm looking through, zu03776 | Date | Re: [stella] Pattern Processor code, Manuel Polik |
| Month |