Below is my code, I have lots of research but I don't get it! I have cobined things that look vaguely similar but they won't go together!
;****************************************************************************************************
; DEFINITIONS
;****************************************************************************************************
list P=PIC16F84A, R=D ;Define PIC type and radix
;(H=Hex, D=Decimal). Hex numbers must
;be of the form 0xAA or 0AAh
include "P16F84A.INC"4 ;P16F84A.INC is a file containing
;definitions of PIC registers
;****** REGISTER USAGE ******
;For PIC16C84, user RAM starts at 0Ch. The following definitions
;(the names are arbitrary) will be found useful in many programs.
count equ 0Ch ;Counter register
flag equ 0Dh ;Counter Flag
msloop equ 0Eh ;Microsecond delay loop register
tenloop equ 0Fh ;Tenth of second delay loop register
secloop equ 10h ;One Second delay loop register
;****************************************************************************************************
; VECTORS
;****************************************************************************************************
;The PIC16C84 vectors live at the bottom of memory (0000h-0007h)
org 0000h ;Reset vector for PIC16C84 is at 0000h
goto start ;Go to main program start
org 0004h ;Interrupt vector for PIC16C84 is at 0004h
goto inter ;Go to start of interrupt service routine
org 0008h ;first location available to programs
;****************************************************************************************************
; SUBROUTINES
;****************************************************************************************************
;By convention, subroutines are placed after the vectors so that they
;are at the bottom of memory. This avoids memory bank-switching for
;small programs.
;Gives a 1 microsecond delay
onems movlw 248 ;Moves number 248 into the working register
movwf msloop ;Moves number from working register to msloop
loop1 nop ;Used for padding
decfsz msloop,1 ;Decrements msloop by 1, skips next instruction if zero
goto loop1 ;Continues to loop until msloop reaches zero
nop ;Used for padding
return
;Gives a 0.1 Second Delay
tenth movlw 100 ;Moves number 100 into the working register
movwf tenloop ;Moves number from working register to tenloop
loop2 call onems ;Calls the 1 microsecond delay subroutine
decfsz tenloop,1 ;Decrements tenloop by 1, skips next instruction if zero
goto loop2 ;Continues to call microsecond delay until tenloop reaches zero
return
;Gives a 1 Second Delay
sec movlw 10 ;Moves number 10 into the working register
movwf secloop ;Moves number from working register to tenloop
loop3 call tenth ;Calls the tenth of a second delay subroutine
decfsz secloop,1 ;Decrements secloop by 1, skips next instruction if zero
goto loop3 ;Continues to call 0.1 second delay until secloop reaches zero
return
;Preset Flashing Output Sequence
outseq bsf PORTB,1 ;Sets bit 1 of output port
call sec ;Calls the one second delay subroutine
bcf PORTB,1 ;Clears bit 1 of output port
call sec ;Calls the one second delay subroutine
goto outseq ;Continues to flash output bit 1 until interrupted
return
;****************************************************************************************************
; MAIN PROGRAM
;****************************************************************************************************
;****** INITIALISATION ******
;Before using the I/O ports, the data direction registers must be set
;up. Bit RP0 in the status register selects either the normal register
;set when 0, or the special register set when 1. The data direction
;registers TRISA and TRISB live in the special register set. A '1' in
;these registers sets the corresponding port line to an Input, and a
;'0' makes the corresponding line an output.
start bsf STATUS,RP0 ;Select special register set
movlw b'11111' ;Set every pin on PORTA to be an Input
movwf TRISA
movlw b'00000000' ;Set every pin on PORTA to be an Ouput
movwf TRISB
bcf STATUS,RP0 ;Select normal register set
;****** MAIN PROGRAM ******
;Reset Count and Flag Registers and Clear Outputs
clrf count ;Clears value in count register
movlw b'00000000' ;Copies binary value 00000000 into working register
movwf PORTB ;Copies value from working register to Output Port
clrf flag ;Clear flag register
;Counting with a flag
wait btfsc PORTA,0 ;Tests bit 0 of Input Port skips next instruction if zero
goto up ;If bit 0 on then program goes to label up
bcf flag,0 ;Clears bit 0 of the flag register
goto wait
up btfsc flag,0
goto wait
bsf flag,0 ;Sets bit 0 of the flag register
incf count,1 ;Increments value in count by 1
;EXOR count register with 100
movlw 100 ;Moves number 100 into working register
xorwf count,0 ;EXORs count with the number in the working register
btfss STATUS,Z ;Checks Status Bit Z to see if all bits in working register are set
goto wait
bsf PORTB,0 ;Sets bit 0 of Output Port if EXOR is successful
;EXOR count register with 200
movlw 200 ;Moves number 200 into working register
xorwf count,0 ;EXORs count with the number in the working register
btfss STATUS,Z ;Checks Status Bit Z to see if all bits in working register are set
goto wait
call outseq ;Calls ouput sequence
What can you do to help me? Thanks