LIST P=16F84
__config 0x3ff9 ;sets the configuration settings
TEMP EQU 0x0c ;(oscillator type etc.)
TRISA EQU 0x85 ; various equates because i couldent get the dos
TRISB EQU 0x86 ; version of mpasm to find the file for the
STATUS EQU 0x03 ; pic16F84A
PORTA EQU 0x05
PORTB EQU 0x06
RP0 EQU 0x05
org 0x00
clrf PORTA
clrf PORTB
bsf STATUS, RP0 ;select bank 1
movlw b'00001111' ;
movwf TRISA ;load A I/O register so bits 0..3 are inputs
movlw b'00000000' ;
movwf TRISB ;set B I/o register to all outputs
bcf STATUS, RP0 ;select bank 0
goto START
TEST_BITS
btfsc TEMP, 0x00 ;test bit 0 , set B bit if A = 1
bsf PORTB, 0x01 ;skip otherwise
btfsc TEMP, 0x01 ;test bit 1 of A
bsf PORTB, 0x02 ;skip if =0
btfsc TEMP, 0x02 ;test bit 2 of A skip if = 0
bsf PORTB, 0x03 ;set B bit otherwise,
btfsc TEMP, 0x03 ;test bit 3 of A skip if 0
bsf PORTB, 0x04 ;set bit 4 otherwise
return
START ; start of program
movf PORTA, 0 ; move port A to accumulator ' W '
movwf TEMP ; move W to temp.
call TEST_BITS ; call sub
goto START ; keep going
end