[A83] Re: Defined Variables


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

[A83] Re: Defined Variables




> ld (VAR),a ;works fine

This is loading an 8-bit register into a single byte, which is of course
fine.

> The error I get is "Unused data in MS byte of argument. (82)", in
reference
> to the line which I have this on (I've tried both):
>
> ld b,VAR
> or
> ld b,(VAR)

These do two separate things.  This first instruction loads the value of
VAR, which is number.  b is an 8-bit register, so it cannot hold a value
larger than 255.  If VAR is greater than 255, then the assembler will warn
you that the data in the Most Significant byte (the high byte) is unused.
The following would work, because bc is a 16-bit register:

 ld bc,VAR

The second instruction loads the value at the memory address (VAR) into b.
At least, it would, if there were an instruction to do that.  You must first
load through the a register, or load the address into hl:

 ld a,(VAR)       ; load the value at memory address VAR
 ld b,a                ; copy it to b

 ld hl,VAR         ; load the value VAR into hl
 ld (hl),b             ; load value at the address point to be hl into b






References: