Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Filename: Lab3.asm
- list p=16f870
- #include <p16f870.inc>
- __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _LVP_OFF & _CPD_OFF ;ovo je za PIC16F870
- #define BANKA0 bcf 3,5
- #define BANKA1 bsf 3,5
- CBLOCK 0X30
- CIFRA1
- CIFRA2
- BROJAC
- INDEKS
- WREG_TEMP
- STATUS_TEMP
- PCLATH_TEMP
- FSR_TEMP
- ENDC
- ORG 0x0000
- goto ResetCode
- ORG 0x0004
- goto InterruptCode
- ResetCode:
- clrf PCLATH
- goto Main
- Main:
- banksel ADCON1
- movlw 0x06
- movwf ADCON1
- banksel PORTA
- clrf PORTA
- clrf PORTB
- banksel TRISA
- clrf TRISA
- clrf TRISB
- clrf TRISC
- bsf TRISB, 1
- movlw b'00000110';
- movwf OPTION_REG
- movlw b'10100000'
- movwf INTCON
- banksel TMR0
- movlw b'11011001'
- movwf TMR0
- clrf BROJAC
- clrf INDEKS
- clrf CIFRA1
- clrf CIFRA2
- banksel PORTB
- delay:
- clrf BROJAC
- delay2:
- goto delay2
- dekodiranje:
- bsf STATUS,RP1
- bcf STATUS,RP0
- ;movf ADDR,W nama je vec cifra u W valjda?
- movwf EEADR
- bsf STATUS,RP0
- bcf EECON1,EEPGD
- bsf EECON1,RD
- bcf STATUS,RP0
- movf EEDATA,W
- banksel PORTC
- return
- InterruptCode:
- movwf WREG_TEMP
- swapf STATUS,W
- clrf STATUS
- movwf STATUS_TEMP
- movf PCLATH,W
- movwf PCLATH_TEMP
- clrf PCLATH
- movf FSR,W
- movwf FSR_TEMP
- btfss INTCON, 2
- goto EndInt
- banksel TMR0
- movlw b'11011001'
- movwf TMR0
- banksel PORTB
- incf BROJAC, f
- btfsc BROJAC, 2
- goto proveraRB1
- vrati:
- incf INDEKS, F
- movf CIFRA1, W;
- btfss INDEKS, 0
- movf CIFRA2, W;
- call dekodiranje
- movwf PORTC
- btfsc INDEKS, 0
- goto cifra2l
- bsf PORTA, 0
- bcf PORTA, 1
- goto kraj3
- cifra2l:
- bcf PORTA, 0
- bsf PORTA, 1
- kraj3:
- bcf INTCON, T0IF
- goto EndInt
- proveraRB1:
- clrf BROJAC
- btfss PORTB, 1
- goto vrati
- goto odugovlaci
- nast1:
- btfss CIFRA2, 3
- goto nast2
- btfss CIFRA2, 0
- goto nast2
- clrf CIFRA2
- incf CIFRA1
- nast2:
- incf CIFRA2
- goto vrati
- odugovlaci:
- btfss PORTB, 1
- goto nast1
- goto odugovlaci
- EndInt:
- bcf 3,5
- movf FSR_TEMP,W
- movwf FSR
- movf PCLATH_TEMP,W
- movwf PCLATH
- swapf STATUS_TEMP,W
- movwf STATUS
- swapf WREG_TEMP,F
- swapf WREG_TEMP,W
- retfie
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement