Assume that in the 0x12 address is stored 0xFD value Write a
Assume that in the 0x12 address is stored 0xFD value. Write a program to convert it to decimal. The decimal digits must be saved in the directions: (0x20, 0x21, 0x22) with the least significant bit starting at 0x20.
Solution
;NUMBER TO BE PLACED AT 30H
;RESULT WILL BE IN 20H,21H,22H
LIST P=PIC16F877A
#INCLUDE<P16F877A.INC>
ORG 0000H
CLRF STATUS
MOVF 30H,0
MOVWF 24H
MOVLW 0X64 ;DIVIDE WITH 100D
MOVWF 25H
CLRF 22H
CLRF 21H
LOOP:
SUBWF 24H,1
INCF 22H
BTFSC STATUS,0
GOTO LOOP
DECF 22H
ADDWF 24H,1
MOVLW 0X0A ;DIVIDE WITH 10D
LOOP1:SUBWF 24H,1
INCF 21H
BTFSC STATUS,0
GOTO LOOP1
DECF 21H
ADDWF 24H,0
MOVWF 20H
CLRF 24H
CLRF 25H
END
