📄 bin4f.asm
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Source File: BIN4F.ASM
; Author: MPB
; Date: 24-11-05
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Output binary count is stopped, started
; and reset with push buttons.
;
; Modified for fast count
; Delay call commented out
;
; Processor: PIC 16F877
;
; Hardware: PIC Demo System
; Clock: RC = 100kHz
; Inputs: Port D: Push Buttons
; RD0, RD1 (active low)
; Outputs: Port B: LEDs (active high)
;
; WDTimer: Disabled
; PUTimer: Enabled
; Interrupts: Disabled
; Code Protect: Disabled
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
PORTD EQU 08 ; Port D Data Register
Timer EQU 20 ; GPR used as delay counter
; Input Bit Label Equates ..................................
Inres EQU 0 ; 'Reset' input button = RD0
Inrun EQU 1 ; 'Run' input button = RD1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Initialise Port B (Port A defaults to inputs).............
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
INCF PORTB ; Increment output at Port B
MOVLW 0FF ; Delay count literal
; CALL delay ; Jump to subroutine 'delay'
GOTO start ; Repeat main loop always
END ; Terminate source code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -