Regarding assembly directives 8086 and DUP

So I ran into a problem that made me question my basic understanding of the DB

(byte definition) and DUP

(duplicate) directives . I understood them like this:

  • NUM DB 34

    will create a variable named NUM and assign it the value 34. Like C char NUM = 34;

    1
  • NUM DB 34 DUP(?)

    Will give me an array of 34 elements, each unassigned.
  • NUM DB 3 DUP(4)

    will give me a NUM array with 3 elements: 4, 4, 4.

It is right?

In my tutorial, I came across:

PRINT_SELECT DB 133 (?)
             DB 123 (?)

      

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


Footnote 1: (editor's note): NUM = 34

in asm defines a build time constant that is not stored in data memory. In MASM syntax assemblers, it works like a variable in some contexts. But, for example, it mul NUM

works only with the memory source, not with the immediate one, while either imul eax, ecx, NUM

or shl ax, NUM

or mov ax, NUM/2

works only with the immediate, not the memory source.

+4


source to share


1 answer


PRINT_SELECT DB 133 (?)
             DB 123 (?)

      

in most assemblers is equivalent to

PRINT_SELECT DB 133 DUP(?)
             DB 123 DUP(?)

      



You can use the 8086 emulator to better understand the 8086 assembly.
Below is a sample code that will explain the directives more.
When you use DB 123 (?)

, you basically reserve 123 consecutive bytes (memory locations) in memory and assign NULL (?) To all of them.

enter image description here

+4


source







All Articles