You are on page 1of 2

ORG 0H #include P16f877A.

inc

; Starting Memory Address

__config _HS_OSC & _WDT_OFF & _LVP_OFF & _PWRTE_ON PORTB EQU 0x06 TRISB EQU 0x86 PORTE EQU 0x07 TRISC EQU 0x87 STATUS EQU 0x03 BSF STATUS, 5 MOVLW B'00000000' MOVWF TRISB BCF STATUS, 5 ; ; ; ; ; Define Define Define Define Define 0x06 0x86 0x07 0x87 0x03 as as as as as PORTB TRISB PORTE TRISE STATUS

; Setting bit5 of STATUS register ; i.e. Selecting Bank 1 ; Move 0x00 to TRISB ; Setting PORTB as output port ; Clearing bit5 of STATUS register ; i.e. Selecting Bank 0

MOVLW E'00000000' MOVWF TRISE BCF STATUS, 5 Case1 MOVLW b'00000100' MOVWF PORTB MOVLW b'100' MOVWF PORTE MOVLW D'50' MOVWF DELAY Loop1 DECFSZ DELAY GOTO Loop1 MOVLW b'00000010' MOVWF PORTB MOVLW b'010' MOVWF PORTE MOVLW D'50' MOVWF DELAY Loop1 DECFSZ DELAY GOTO Loop1 MOVLW b'00000001' MOVWF PORTB MOVLW b'001' MOVWF PORTE

; Move 0x00 to TRISB ; Setting PORTB as output port ; Clearing bit5 of STATUS register ; i.e. Selecting Bank 0

; ; ; ; ;

Setting counter value of 50 Moving count value to DELAY Creating the delay Decrement, skip next if DELAY=0 Next instruction

; ; ; ; ;

Setting counter value of 50 Moving count value to DELAY Creating the delay Decrement, skip next if DELAY=0 Next instruction

MOVLW D'50' MOVWF DELAY Loop1 DECFSZ DELAY GOTO Loop1 Case2 MOVLW b'00000010' MOVWF PORTB MOVLW b'010' MOVWF PORTE MOVLW D'50' MOVWF DELAY Loop1 DECFSZ DELAY GOTO Loop1 MOVLW b'00000100' MOVWF PORTB MOVLW'100' MOVWF PORTE GOTO Case1 END

; ; ; ; ;

Setting counter value of 50 Moving count value to DELAY Creating the delay Decrement, skip next if DELAY=0 Next instruction

; ; ; ; ;

Setting counter value of 50 Moving count value to DELAY. Creating the delay Decrement, skip next if DELAY=0 Next instruction

You might also like