Example
1:
Rotate accumulator right
six
times.
ROTR6:
Example
2:
REPT
RRC
ENDM
6
Chapter
5.
Macros
The following
REPT
directive generates the source code for a routine that fills a five-byte field with the character
stored
in
the accumulator:
Example
3:
PROGRAM CODE
LHLD
REPT
MOY
INX
ENDM
CNTR1
5
M,A
H
GENERA TED CODING
LHLD
CNTR1
MOY
M,A
INX
H
MOY
M,A
INX
H
MOY
M,A
INX
H
MOY
M,A
INX
H
MOY
M,A
INX
H
The following example illustrates the
use
of
REPT
to generate a multiplication routine. The multiplication
is
accomplished through a series of shifts.
If
this technique
is
unfamiliar, refer to the example of multiplication
in
Chapter 6. The example
in
Chapter 6
uses
a program loop for the multiplication. This example replaces the
loop with seven repetitions
of
the four instructions enclosed
by
the
REPT
-ENDM directives.
Notice that the expansion specified
by
this
REPT
directive causes the
label
SKIPAD to
be
generated seven times.
Therefore, SKIPAD must
be
declared local
to
this macro.
FSTMUL:
SKIPAD:
MYI
L.XI
REPT
LOCAL
RLC
INC
DAD
DAD
ENDM
RLC
RNC
D,O
H,O
7
SKIPAD
SKIPAD
D
H
DAD
D
RET
;FAST MULTIPLY ROUTINE
;MULTIPLY E*A - 16-BIT RESULT
;IN
H&L
;;GET
NEXT
MULTIPLIER
BIT
;;DON'T
ADD
IF
BIT
=:
°
;;ADD
MULTIPLICAND
INTO
ANSWER
5-7