PSW EQU 03
R0 EQU 08
R1 EQU 09
R2 EQU 0AH
R3 EQU 0BH
R4 EQU 0CH
R5 EQU 0DH
R6 EQU 0EH
R7 EQU 0FH
TEMP EQU 13H
CNT1 EQU 11H
CNTH EQU 12H
BUF0 EQU 17H
BUF1 EQU 18H
ESUM1 EQU 13H
ESUM2 EQU 14H
ESUM3 EQU 15H
ESUM4 EQU 16H
DSUM1 EQU 19H
DSUM2 EQU 1AH
DSUM3 EQU 1BH
DSUM4 EQU 1CH
DSUM5 EQU 1DH
DSUM6 EQU 1EH
ORG 1FFH
GOTO RADM
ORG 000
D_ADD MOVF R0,0
ADDWF R6,1
BTFSC PSW,0
INCF R7
MOVF R1,0
ADDWF R7,1
RETLW 0
DMU1 MOVLW 16
MOVWF TEMP
CLRF R7
CLRF R6
DMUL_1 RRF R3
RRF R2
BTFSC PSW,0
CALL D_ADD
RRF R7
RRF R6
RRF R5
RRF R4
DECFSZ TEMP
GOTO DMUL_1
RETLW 0
RADM CLRF ESUM1
CLRF ESUM2
CLRF ESUM3
CLRF ESUM4
CLRF DSUM1
CLRF DSUM2
CLRF DSUM3
CLRF DSUM4
CLRF DSUM5
CLRF DSUM6
MOVLW 20H
MOVWF CNTH
RADM_1 MOVLW 00
MOVWF CNTL
RADM_2 MOVLW 64H
MOVWF R3
MOVLW 85H
MOVWF R2
MOVF BUF1,0
MOVWF R1
MOVF BUF0,0
MOVWF R0
CALL DMUL
MOVLW 19H
ADDWF R4,0
MOVWF R0
MOVWF BUF0
BTFSC PSW,0
INCF R5
MOVLW 36H
ADDWF R5,0
MOVWF R1
MOVWF BUF1
MOVF R0,0
ADDWF ESUM1,1
BUFSS PSW,0
GOTO EADD_1
INCF ESUM2
BTFSS PSW,2
GOTO EADD_1
INCF ESUM3
BTFSS PSW,2
GOTO EADD_1
INCF ESUM4
EADD_1 MOVF R1,0
ADDWF ESUM2,1
BTFSS PSW,0
GOTO EADD_2
BTFSS PSW,2
GOTO EADD_2
INCF ESUM4
EADD_2 BTFSC R1,7
GOTO RADM_3
COMF R0,1
COMF R1,1
MOVLW 1
ADDWF R0,1
BTFSC PSW,0
INCF R1
RADM_3 MOVLW 80H
ADDWF R1,1
MOVF R1,0
MOVWF R3
MOVF R0,0
MOVWF R2
CALL DMUL
MOVF R4,0
ADDWF DSUM1,1
BTFSS PSW,0
GOTO DADD_1
INCF DSUM2
BTFSS PSW,2
GOTO DADD_1
INCF DSUM3
BTFSS PSW,2
GOTO DADD_1
INCF DSUM4
BTFSS PSW,2
GOTO DADD_1
INCF DSUM6
DADD_1 MOVF R5,0
ADDWF DSUM2,1
BTFSS PSW,0
GOTO DADD_2
INCF DSUM3
BTFSS PSW,2
GOTO DADD_2
INCF DSUM4
BTFSS PSW,2
GOTO DADD_2
INCF DSUM5
BTFSS PSW,2
GOTO DADD_2
INCF DSSUM6
DADD_2 MOVF R6,0
ADDWF DSUM3,1
BTFSS PSW,0
GOTO DADD_3
INCF DSUM4
BTFSS PSW,2
GOTO DADD_3
INCF DSUM5
BTFSS PSW,2
GOTO DADD_3
INCF DSUM6
DADD_3 MOVF R7,0
ADDWF DSUM4,1
BTFSS PSW,0
GOTO DADD_4
INCF DSUM5
BTFSS PSW,2
GOTO DADD_4
INCF DSUM6
DADD_4 DECFSZ CNTL
GOTO RADM_2
DECFSZ CNTH
GOTO RADM_1
MOVLW 5
MOVWF CNTL
RADM_4 BCF PSW,0
RRF ESUM4
RRF ESUM3
RRF ESUM2
RRF ESUM1
DECFSZ CNTL
GOTO RADM_4
MOVLW 5
MOVWF CNTL
RADM_5 BCF PSW,0
RRF DSUM6
RRF DSUM5
RRF DSUM4
RRF DSUM3
RRF DSUM2
RRF DSUM1
DECFSZ CNTL
GOTO RADM_5
LOOP GOTO LOOP
END