What Is An Assembler?: 0045h. This Is Good, Since This Way We Can Access Much More Memory Than
What Is An Assembler?: 0045h. This Is Good, Since This Way We Can Access Much More Memory Than
The dumb translator that will convert these mnemonics back to the original opcodes is a key
program to be used throughout this course and is called the assembler.
Load
Effective
Address.
Algorithm:
#make_COM#
ORG 100h
LEA AX, m
RET
m DW 1234h
END
AX
is
set
to:
0104h.
LEA instruction takes 3 bytes, RET takes 1 byte, we start at 100h, so the address of 'm' is 104h.
CZSOPA
unchanged
for
variable
declaration:
name
DB
value
name
DW
value
DB
stays
for
Define
Byte.
DW
stays
for
Define
Word.
name - can be any letter or digit combination, though it should start with a letter. It's possible
to declare unnamed variables by not specifying the name (this variable will have an address
but
no
name).
value - can be any numeric value in any supported numbering system (hexadecimal, binary,
or decimal), or "?" symbol for variables that are not initialized.
Unsigned
multiply.
Algorithm:
when
AX = AL * operand .
operand
is
byte:
when
operand
(DX AX) = AX * operand .
is
word:
Example:
M O V A L, 200 ; A L = 0C 8h
M O V BL, 4
M U L BL
; A X = 0320h (800)
RE T
CZSOPA
r ? ? r ? ?
CF=OF=0 when high section of the result is zero.
Exchange
values
of
two
operands.
>
operand2
Algorithm:
operand1
<
Example:
M O V A L, 5
M O V A H, 2
X C HG A L, A H ; A L = 2, A H = 5
X C HG A L, A H ; A L = 5, A H = 2
RE T
CZSOPA
unchanged
Subtract.
Algorithm:
operand1
operand1
operand2
Example:
M O V A L, 5
SU B A L, 1
; AL = 4
RE T
CZSOPA
r r r r r r
Procedures
Procedure is a part of code that can be called from your program in order to
make some specific task. Procedures make program more structural and
easier to understand. Generally procedure returns to the same point from
where
it
was
called.
The syntax for procedure declaration:
name
PROC
;
;
here
of
goes
the
the
procedure
code
...
RET
name ENDP
Macros
Macros are just like procedures, but not really. Macros look like procedures,
but they exist only until your code is compiled, after compilation all macros
are replaced with real instructions. If you declared a macro and never used it
in your code, compiler will simply ignore it. emu8086.inc is a good example
of how macros can be used, this file contains several macros to make coding
easier for you.
Macro definition:
nam e
M A C RO [param eters,...]
Unlike procedures, macros should be defined above the code that uses it, for
example:
M yM acro
M A C RO p1, p2, p3
M O V A X, p1
M O V BX , p2
M O V C X , p3
ENDM
O RG 100h
M yM acro 1, 2, 3
M yM acro 4, 5, D X
RE T