Re: A82: TEXT_MEM vars


[Prev][Next][Index][Thread]

Re: A82: TEXT_MEM vars



At 06:32 PM 11/23/97 -0600, you wrote:
>you can only use the a register to load to/from memory locations:
>Example:
>ld a,(score)
>ld (score),a
>
>There you go....

Not true unless you are using 8-bit registers exclusively.  You can also
use the 16 bit registers to load from/to memory.  However, when you write a
16-bit register to memory, it is written backwards (e.g.  ld (TEXT_MEM),bc
will load c -> (TEXT_MEM) and b -> (TEXT_MEM+1)).

The same thing also applies when reading a 16-bit register from memory, it
is read backwards (e.g.  ld bc,(TEXT_MEM) will load (TEXT_MEM) -> c and
(TEXT_MEM+1) -> b).

This information is pointless if you are just using 8-bit or 16-bit
registers exclusively.  However, when you start mixing the two types, you
can start to run into problems if you don't remember this.  Here are all
the legal commands the Z80 processor uses for memory storage/retrieval
commands using variables (not register locations such as ld a,(hl)):

ld a,(NN)
ld (NN),a
ld bc,(NN)
ld (NN),bc
ld de,(NN)
ld (NN),de
ld hl,(NN)
ld (NN),hl
ld ix,(NN)
ld (NN),ix
ld iy,(NN)     Don't forget to DI and save IY before using
ld (NN),iy     these commands!

Hope that helps

                 Thomas J. Hruska -- thruska@tir.com
Shining Light Productions -- "Meeting the needs of fellow programmers"
         http://www.geocities.com/SiliconValley/Heights/8504
                    http://shinelight.home.ml.org

  Spam-Fighter code is:  14806560   (New technique to fighting spam)
  Enter "Spam-Fighter:  XXXXXXXX" in the body of a personal message
  to thruska@tir.com.  Otherwise the message will be filtered as spam.


References: