I'm trying to learn Assembly language. I noticed that it's totally different compared to high-level programming languages like Java.
So I read that a data transfer instruction follows this syntax:
mnemonic destination, source
which I see as destination = source
In other words, assignment of value to a memory.
I saw an example in the book this data segment declaration.
.data
var1 SBYTE -4,-2,3,1
var2 WORD 1000h,2000h,3000h,4000h
var3 SWORD -16,-42
var4 DWORD 1,2,3,4,5
Howcome there are > 1 value for the variables? What does that exactly mean?
I'd appreciate any explanation.
Thanks.
To define multiple WORD-sized variables in assembly we can use
var1 WORD 1000h
var2 WORD 2000h
var3 WORD 3000h
var4 WORD 4000h
Often the programmer doesn't need to name every single variable, just the first one and then use pointer arithmetic to get to the others.
In this case we can use
var1 WORD 1000h
WORD 2000h
WORD 3000h
WORD 4000h
This is especially handy when some variables may have a different sizes, otherwise the repeating of the keyword WORD is annoying and can be simplified in the final form
var1 WORD 1000h, 2000h, 3000h, 4000h
Which is equivalent to the second form and (names aside) to the first form.