bin4d.asm

来自「PROTEUS仿真PIC16F877的例子」· 汇编 代码 · 共 59 行

ASM
59
字号
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;       Source File:	BIN4D.ASM		
;	Author:		MPB              
;	Date:		13-11-05 
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	Slow output binary count is stopped, started
;       and reset with push buttons. 
;       Modified with extra directives
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 

; 	Declare processor, supress messages and warnings,
;	do not print symbol table, and configure (RC clock)

	LIST p=16f877a, w=2, st=off, mm=off
	__CONFIG 0x3733		

;	Declare GPR label and literal constant
;	Define input labels 
;       Include standard SFR label file
;	Include PortB initialisation file

Timer EQU 20
DDCodeB SET b'00000000'
CONSTANT Count=003
#DEFINE RunBut PORTD,1
#DEFINE ResBut PORTD,0
#INCLUDE "P16F877A.INC"
#INCLUDE <BOUT.INI>

; Program code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; 'delay' macro .............................................
        
delay  	MACRO			; macro definition starts
	MOVWF  	Timer          	; Copy W to timer register
down    DECF	Timer          	; Decrement timer register 
        BNZ	down           	; and repeat until zero
	ENDM			; macro definition ends

; Main loop .................................................

reset   CLRF    PORTB  		; Clear Port B Data 

start   BTFSS  	ResBut   	; Test reset button
       	GOTO   	reset          	; and reset Port B if pressed
        BTFSC  	RunBut   	; Test run button
        GOTO  	start          	; and repeat if n pressed

        INCF   	PORTB          	; Increment output at Port B 
	MOVLW  	Count          	; Delay count literal
	delay			; Jump to subroutine 'delay'
        GOTO   	start          	; Repeat main loop always

        END                   	; Terminate source code......

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?