RE: A83: Question About Storing Words (.dw)


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

RE: A83: Question About Storing Words (.dw)




>I saw this message, and I remembered that I wanted to find out how the .dw
>statements work. Could someone please tell me how to use them and what they
>are used for?

.dw tels the compiler you want to allocate some space to store a word(2 
bytes), just like .db allocates some space for a byte. You can use this as 
var's:

;-------------------------------------
      ld a,(byte)          ; a now contains the value stored in 'byte'
      inc a                ; a+1->a  (a=5)
      ld (byte),a          ; put a back to 'byte'
      ld hl,2345h          ; load 2345h into hl
      ld (word),hl         ; save hl to 'word'
      ret                  ; return before data, else the Z80 will
                           ; continue prosessing our data --> calc
                           ; will crash
byte: .db 4
word: .dw 1234h
;-------------------------------------

hope this helps!

Sebastiaan


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com