Page 1 of 1

Very simple assembly question: labels vs variables

Posted: Fri Oct 28, 2011 5:58 pm
by theseankelly
Okay, so I'm not a novice to programming and I'm rather embarrassed to ask such a simple question...but I'm getting frustrated with trying to rephrase "assembly lables vs variables" into something that'll produce meaningful results in Google.

BUT.

I'm failing to see any functional difference between the following two lines:

Code: Select all

string1  db 'Hello',0
string1: db 'Hello',0
Is that because there actually is no difference?

It seems like most variables and string constants are always the first one, but then when I see example code for things like disk address packets and bios parameter blocks, they use labels instead of variable names to isolate certain parts. Why?

Re: Very simple assembly question: labels vs variables

Posted: Fri Oct 28, 2011 7:16 pm
by psychobeagle12
also, not that it really makes a difference, but if (in nasm) you try to use the form label on a line of its own as such:

Code: Select all

label

     mov ax,bx
nasm will produce the message "label alone on a line without a colon might be an error." I would assume that this is in case you forget to add a space declarator on a line. Other than this, no, it serves no functional difference other than to remind you that one is code and one declares space.