1
value db 0h, 10h

value dw 10h

Are they the same? What is the difference?

If I used, for example,

ld A, (value)

What would happen in both cases?

2 Answers2

4
value db 0h, 10h

the machine code produced is (hexa bytes): 00 10

value dw 10h

the machine code produced is (hexa bytes): 10 00 (because Z80 is little-endian CPU)

ld A, (value) will load A with value: in first case 0, and second 16.

Ped7g
  • 16,236
  • 3
  • 26
  • 63
  • So am I right to assume that (value) stands for the first byte thatis assigned? Thanks, by the way – Francisco José Letterio Nov 12 '17 at 05:54
  • 1
    @FranciscoJoséLetterio of course... I mean, `value` is not a "variable", but a label. It doesn't care, if the `db`, `dw` or some instruction follows it, it's like bookmark of \*here\* into memory. So `(value)` is memory content from that address. How many bytes are used depends, `ld A,(1234)` loads 1 byte, `ld HL,(1234)` loads 2 bytes as word value, both starting at address 1234. – Ped7g Nov 12 '17 at 06:58
2

db = data byte = 1 byte

dw = data word = 2 bytes, which are in the little endian order

Harper Maddox
  • 540
  • 4
  • 8