Intel mcs-48 Microscope & Magnifier User Manual


 
APPLICATION EXAMPLES
DOUBLE EXCHANGE
DEX:
DEC
XCH
INC
XCH
XCH
XCH
RET
RXO
;EXCHANGE A AND LOW BYTE
A,@RXO
RXO
;EXCHANGE AEX AND HIGH BYTE
A,AEX
A,@RXO
A,AEX
;RETURN
DOUBLE LEFT LOGICAL SHIFT
LLSH: RLC A ;SHIFT A
XCH A,AEX
;SHIFT AEX
RLC A
XCH A,AEX
RET ;RETURN
DOUBLE RIGHT LOGICAL SHIFT
RLSH: XCH A,AEX ;SHIFT AEX
A
A,AEX
RRC
XCH
RRC
RET
A ;SHIFT A
;RETURN
DOUBLE RIGHT ARITHMETIC SHIFT
RASH: CLR C ;SET CARRY
CPL C
XCH
A,AEX
;IF AEX[7]<>1 THEN
JB7
$+3
CLR
C
;CLEAR CARRY
RRC A ;SHIFT C INTO AEX
XCH A,AEX
RRC A
;SHIFT A
RET
;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-O
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)
5-23
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).