0

I am compiling the next snippet

.data
k db 'Hello, world!',13,10,0
.code
mov ax,word ptr ds:[k]

It is explicitly pointed that I move a word into ax. Since we know that ax takes 2 bytes, why do I need to point that out in the in-memory operand?

alexander.sivak
  • 4,352
  • 3
  • 18
  • 27
  • 1
    You don't, unless `k` has been defined with a different type but you did not show that. I believe masm is trying to be helpful in catching type mismatch errors. – Jester Nov 06 '20 at 11:27
  • You don't need the `ds:` prefix, only the `word ptr` operand-size override. (And yes, as Jester says that's because MASM "variable" declarations (label + db / dw / dd / dq) imply a size, unlike if you use `k:` `db ...`, if MASM allows that. (Support for a `:` in that context might vary by version, I don't remember the full details of explanations of if/how you can get MASM to *not* treat labels as "variables"). – Peter Cordes Nov 06 '20 at 12:29

0 Answers0