Clueless about assembly

Thread Starter

nanobyte

Joined May 26, 2004
120
:unsure: :blink: Hi everybody. I am currently taking a course in 80x86 intel assembly programming language. Everyday in this class has been a struggle and I am pretty sure I'm going to have to retake the course. One of my infinite amount of problems right now is that I am not understanding LABEL directives. What exactly are they? What do they do? And what is the advantage of them? Please explain this as if you were talking to a 8 year old because I'll be the first to tell you that I'm not that bright.
 

pebe

Joined Oct 11, 2004
626
Originally posted by nanobyte@Feb 1 2005, 03:29 AM
:unsure:  :blink: Hi everybody.  I am currently taking a course in 80x86 intel assembly programming language.  Everyday in this class has been a struggle and I am pretty sure I'm going to have to retake the course.  One of my infinite amount of problems right now is that I am not understanding LABEL directives.  What exactly are they?  What do they do?  And what is the advantage of them?  Please explain this as if you were talking to a 8 year old because I'll be the first to tell you that I'm not that bright.
[post=4957]Quoted post[/post]​
I've not worked with Intel 8086, though I've used Intel 8048. PIC and ST62 series. But I assume that the use of 'Label' in those may be the same. If I relate my experiences, they may help the explanation.

I started using machine code with an 8048 some 30 years ago because PCs weren't around then. Every instruction had a Hex number so that part was easy. The problem came when I had to do a branch or jump to another part of the program yet to be written, so I couldn't put in the 'jump-to' address. The result was I had to leave large gaps between each section of the program to ensure enough room and use fixed jump addresses that could be coded. Having written the program, the code was then relocated into contiguous blocks and the jump addresses redefined. A very laborious job!

Then I got my first computer and an 8048 assembler. Life suddenly became easier. Simple mnemonics were used for instruction codes and 'jump' and 'branch-to' addresses were represented by labels, so it was not necessary to know their absolute addresses - so a jump became something like 'JMP newprog'. When the program was written it was assembled. The assembler compiled the code and allocated memory addresses for each instruction sequentially, taking note of the jump-to addresses. Then it did a second pass replacing all the labels with their correct absolute addresses.

That was the essential difference between machine code and assembler. Does that make sense of labels?
 

havøc

Joined Feb 12, 2005
1
For all its worth, labels are simply what the name implies - labels in a source code. Maybe an example would better explain it. Here goes [this is just a snippet]

Rich (BB code):
W8:
 MOV AH,1
 INT 16h
 JZ W8
In the above example, W8 is a label, which is sort of a bookmrk in the code. The code snippet is actually a "wait until keypressed" subroutine. Int 16h Function 1 checks the keyboard buffer for any keystrokes, and if there's something, the scan code is stored in AH; if there's no pending keystroke, AH contains 0. If there's none (JZ W8) then the program is going to loop back to "W8." This goes on and on until a key is present in the keyboard buffer, in which case AH does not contain 0 anymore so JZ W8 is no longer valid.

Hope this helps. :D
 

cyberhehe

Joined Oct 6, 2004
61
Originally posted by nanobyte@Feb 1 2005, 10:29 AM
:unsure: :blink: Hi everybody. I am currently taking a course in 80x86 intel assembly programming language. Everyday in this class has been a struggle and I am pretty sure I'm going to have to retake the course. One of my infinite amount of problems right now is that I am not understanding LABEL directives. What exactly are they? What do they do? And what is the advantage of them? Please explain this as if you were talking to a 8 year old because I'll be the first to tell you that I'm not that bright.
[post=4957]Quoted post[/post]​
Directives are basically sort of commands/tools that the compiler is using, preprocessed before actual assembly compile starts. one of the directives, example is the ORG XXX which commands the compiler to set the current active address during compile to be at XXX.

LABEL directives on the other hand are directives that provide you address reference, instead of using the actual address. Imagine, if you are using assembly programming for the 80X86 platform utilizing all as instructions sets, numbers and addresses, that will give you a hell of programming confusion (who would want to memorize all those addresses). To give convenience to the assembly language software code development it will then be easier for the developer to use "LABEL"s instead of pure addresses, making life more easier to code with :D

DIRECTIVES are comliper commands and not and instruction set included in the platform you are using.
 
Top