
52
CHAPTER 2 BASICS OF SOFTWARE
; Multiplicand area
; Multiplier area
; Work area
; Operation result storage area
;
;
; Stores multiplier (low) in work area
; Initializes operation result storage area
;
;
;
; Stores higher multiplier in work area
; if low multiplication is completed
;
;
; Shifts multiplier 1 bit to left
;
;
;
; Adds multiplicand to operation
;
result storage area if carry occurs
;
;
;
;
;
; Shifts operation result storage area 1 bit to left
;
;
;
;
;
;
(4) Program list
$PC(014)
;
PUBLIC HIKAKE,S_KAKERU,KAKE,KOTAE
;
;************************************************
;
RAM definition
;************************************************
DSEG
SADDR
HIKAKE:
DS
2
KAKE:
DS
2
WORK1:
DS
1
KOTAE:
DS
4
;
;************************************************
;
Multiplication
;************************************************
CSEG
S_KAKERU:
WORK1=KAKE+1 (A)
KOTAE=#0
KOTAE+1=#0
KOTAE+2=#0
KOTAE+3=#0
for(B=#0;B<#16;B++)(A)
if(B == #8)(A)
WORK1=KAKE (A)
endif
A=WORK1
CLR1
CY
ROLC
A,1
WORK1=A
if_bit(CY)
KOTAE+=HIKAKE (A)
(KOTAE+1)+=HIKAKE+1,CY (A)
(KOTAE+2)+=#0,CY (A)
(KOTAE+3)+=#0,CY (A)
endif
if(B != #15) (A)
KOTAE+=KOTAE (A)
KOTAE+1+=KOTAE+1,CY (A)
KOTAE+2+=KOTAE+2,CY (A)
KOTAE+3+=KOTAE+3,CY (A)
endif
next
RET
END