- though the assembler language is freeform like C, we adhere to a standard format for clarity
- general form of the lines of a program are denoted by fields
LABEL FIELD2 OPERAND(S) ; comment | | | | Convenient tab stops
VARIABLE
is equivalent to variable
0
and postfixed with a h
are interpreted as hexadecimal
Form:
<label> <pseudo-instruction/assembler directive>
-or-
<label>: <instruction>
<LABEL>
corresponds to a variable name, procedure name, or a branching label -->
@, $, _, and ?
.
dataseg
Contains:
segments in an assembly program: STACK, DATA, CODE
Form:
<name> SEGMENT <option1> <option2> ... <optionN> . . . <name> ENDS
example:
StackSeg SEGMENT STACK para 'STACK' DB 32 DUP("STACK**") StackSeg ENDS
Option 1 - STACK
Must contain STACK
so it can be combined with other stack segments by the assembler.
Option 2 - para
Sets the kind of address at which hte physical address begins.
para
is default
Option 2 - 'STACK'
Assigns the stack a name used by a debugger
Optional, not always used.
Shortcut definition
.STACK N
Where N
is the number of bytes to reserve. All defaults are used.
example:
DatSeg SEGMENT para 'DATA' . . . DatSeg ENDS
Shortcut definition
.DATA
example:
CodeSeg SEGMENT para 'CODE' ASSUME ss: StackSeg ... . . . CodeSeg ENDS
There are 14 segment registers on the 8086
cs
- pointer to active code segment
ss
- pointer to active stack segment
ds
- pointer to active data segment
es
- pointer to active extended segment
The last line ends with:
END <startlabel>
example:
program: . . . END program
CODE
Segment