;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Source File: lab 01_2.ASM ; Author: أكتب رقمك الجامعي هنا ; Date: أكتب تاريخ مختبرك ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PROCESSOR 16F877 ; Define MCU type ;__CONFIG 0x3733 ; Set config fuses ; Register Label Equates.................................... PORTB EQU 06 ; Port B Data Register TRISB EQU 86 ; Port B Direction Register Timer EQU 20 ; GPR used as delay counter ; Input Bit Label Equates .................................. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Initialise Port B (Port A defaults to inputs)............. ORG 0XA BANKSEL TRISB ; Select bank 1 MOVLW b'00000000' ; Port B Direction Code MOVWF TRISB ; Load the DDR code into F86 BANKSEL PORTB ; Select bank 0 GOTO reset ; Jump to main loop ; 'delay' subroutine ........................................ delay MOVWF Timer ; Copy W to timer register down DECFSZ Timer ; Decrement timer register GOTO down ; and repeat until zero RETURN ; Jump back to main program ; Start main loop ........................................... reset CLRF PORTB ; Clear Port B Data ;start BTFSS PORTD,Inres ; Test reset button ; GOTO reset ; and reset Port B if pressed ;; BTFSC PORTD,Inrun ; Test run button ; GOTO start ; and repeat if n pressed WDT clrwdt INCF PORTB ; Increment output at Port B MOVLW 0FF ; Delay count literal CALL delay ; Jump to subroutine 'delay' GOTO WDT ; Repeat main loop always END ; Terminate source code