Intel MCS48 User Manual page 143

Family of single chip microcomputers
Hide thumbs Also See for MCS48:
Table of Contents

Advertisement

APPLICATION
EXAMPLES
DOUBLE
DEX:
EXCHANGE
RXO
DEC
XCH
INC
XCH
XCH
XCH
RET
A,@RX0
RXO
A.AEX
A,@RX0
A.AEX
;EXCHANGE
A
AND
LOW
BYTE
EXCHANGE
AEX AND
HIGH BYTE
DOUBLE
LLSH:
;RETURN
LEFT
LOGICAL
SHIFT
RLC
XCH
RLC
XCH
RET
A
A.AEX
A
A.AEX
;SHIFT
A
;SHIFT
AEX
DOUBLE
RLSH:
;RETURN
RIGHT LOGICALSHIFT
;SHIFT
AEX
XCH
RRC
XCH
RRC
RET
A.AEX
A
A.AEX
A
;SHIFT
A
;RETURN
DOUBLE
RASH:
RIGHT ARITHMETIC
SHIFT
;SET
CARRY
CLR
CPL
XCH
JB7
CLR
RRC
XCH
RRC
RET
C
C
A,AEX
$+3
C
A
A.AEX
A
;IF
AEX[7]<>1
THEN
;CLEAR
CARRY
;SHIFT
C INTO AEX
;SHIFT
A
;RETURN
SINGLE PRECISION BINARY MULTIPLY
This
routine
assumes
a
one-byte
multiplier
and
a one-byte
multiplicand.
The
product,
therefore,
is
two-bytes
long.
The
algorithm follows these
steps:
1.
The
registers
are
arranged
as
follows:
ACC
R1
Multiplier
R2
Multiplicand
R3
Loop
Counter
(=8)
The
Accumulator and
register
R1
are
treated
as a
register pair
when
they
are
shifted
right
(see
Step
2)
2.
The
Accumulator and
R1
are
shifted
right
one
place,
thus the
LSB
of
the
multiplier
goes
into
the
carry.
3.
The
multiplicand
is
added
to
the
accumulator
if
the carry
bit
is
a
'one'.
No
action
if
the carry
is
a
'zero'.
4.
Decrement
the loop
counter
and
loop
(return to
Step
2) until
it
reaches
zero.
5.
Shift
the
result right
one
last
time
just
before
exiting
the routine
*The
result
will
be found
in
the
Accumulator
(MS
Byte)
and
R1 (LS
Byte).
5-23

Advertisement

Table of Contents
loading

Table of Contents