;*****Define Registers*****
PC equ 02h
STATUS equ 03h
PORTA equ 05h
PORTB equ 06h
TRISA equ 85h
TRISB equ 86h
CounterL equ 0Dh
CounterH equ 0Eh
Digit1 equ 10h
Digit2 equ 11h
;*****initialization*****
bsf STATUS,5 ;Switch to Bank 1
movlw b’00111001'
movwf TRISA ;RA0 I/P RA1,2 O/P
clrf TRISB ;PORT B output
bcf STATUS,5 ;Switch to Bank 0
clrf Digit1 ;initilize to zero
clrf Digit2 ;initilize to zero
;**display the first digit**
Loop bcf PORTA,2 ;disable digit2
movf Digit1,0 ;get digit1 value
call Table ;Look Up Table
movwf PORTB ;Writ the number
bsf PORTA,1 ;enable digit1
;**small delay to display digit1**
Delay1 decfsz CounterL,1
goto Delay1
;**display the second digit**
bcf PORTA,1 ;disable digit1
movf Digit2,0 ;get digit2 value
call Table ;Look Up Table
movwf PORTB ;Writ the number
bsf PORTA,2 ;enable digit2
;**small delay to display digit2**
Delay2 decfsz CounterL,1
goto Delay2
btfss PORTA,0 ;Button pressed?
goto Countup ;If yes Count up
goto Loop ;else back to Loop
;**Update Digit1 and Digit2**
Countup incf Digit1,1 ;increase Digit1
movlw D’10' ;load w with ten
xorwf Digit1,0 ;compare with 10
btfss STATUS,2 ;if equal result 0
goto Loop ;else back to Loop
clrf Digit1 ;make Digit1 = 0
incf Digit2,1 ;increase Digit1
movlw D’10' ;load w with ten
xorwf Digit2,0 ;compare with 10
btfsc STATUS,2 ;if equal result 0
clrf Digit1 ;make Digit2 = 0
goto Loop ;back to Loop
;****Look Up Table for bit patterns****
Table addwf PC,1
retlw b’00111111' ;Number 0
retlw b’00000110' ;Number 1
retlw b’01011011' ;Number 2
retlw b’01001111' ;Number 3
retlw b’01100110' ;Number 4
retlw b’01101101' ;Number 5
retlw b’01111101' ;Number 6
retlw b’00000111' ;Number 7
retlw b’01111111' ;Number 8
retlw b’01100111' ;Number 9
end
vidusara eke giya counter eka hari kamam ne asm kara ganna widihak......?