icebox19
icebox19

Reputation: 523

Difference between word ptr d, and word ptr + 2 for assembly 8086

What is the difference between:

1st

mov cx, word ptr d

-loads a word size value of d into cx

2nd

mov cx, word ptr d + 2

-what does that + 2 do ?

Upvotes: 1

Views: 282

Answers (2)

Michael
Michael

Reputation: 58467

In MASM/TASM syntax (which your code seems to be using), mov cx, word ptr d means the same thing as mov cx, word ptr [d]. So mov cx, word ptr d + 2 is the same as mov cx, word ptr [d + 2] (i.e. it's reading a word from the address of d plus 2 and storing the value in cx).

Upvotes: 2

Some programmer dude
Some programmer dude

Reputation: 409206

If I'm not misremembering, it adds an offset to the address d.

Upvotes: 0

Related Questions