Regarding 8086 assembly's DB and DUP directives

Viewed 12497

So I've encountered a problem that made me question my basic understanding of the DB (define byte) and DUP (duplicate) directives. The way I've understood them is:

  • NUM DB 34 will create a variable named NUM and it will assign it with the value 34. Like C char NUM = 34;1
  • NUM DB 34 DUP(?) will give me an array of 34 items, each of them unassigned.
  • NUM DB 3 DUP(4) would give me an array called NUM with 3 items: 4, 4, 4.

Is this correct?

In my textbook I encountered:

PRINT_SELECT DB 133 (?)
             DB 123 (?)

Is this just a mistake in the textbook, or do these two lines of code mean something else completely?


Footnote 1: (editor's note): NUM = 34 in asm defines an assemble-time constant not stored in data memory. In MASM-syntax assemblers, it works similarly to a variable in some contexts. But for example mul NUM only works with a memory source, not an immediate, while imul eax, ecx, NUM, or shl ax, NUM, or mov ax, NUM / 2 only works with an immediate, not a memory source.

1 Answers
Related