prog27.asm

来自「主要是8051源代码」· 汇编 代码 · 共 36 行

ASM
36
字号
;  PROG27 -  Polling 8 Data Pins on the Data Bus 
;
;  This Application Reads the 8 switches at Address 00000h (or Address 00100h)
;   on the Address bus and Displays them on the LEDs connected to P1.  
;
;  Myke Predko
;  98.03.09
;
;  Hardware Notes:
;  80C520 Running at 4 MHz
;  P1.0 is Connected to a Set of LEDs
;  P3.2 is Connected to momentary On Pull Down Button
;  P0/P2 I/O Bus wired to a 74LS245 with 8 Input Switches

;  Variable Declarations

 org 000h
  mov   DPTR,#0                 ;  Initialize DPTR to the I/O Address

Loop:                           ;  Loop Polling the Port and Outputting the Data

  mov   A,P3                    ;  Get the Specified Address
  
  mov   C,ACC.2                 ;  Save the Button Value in Carry

  clr   A                       ;  Clear The Accumulator

  mov   ACC.0,C
  mov   DPH,A                   ;  Update the DPTR To the Address

  movx  A,@DPTR                 ;  Read the External I/O Port
  cpl   A                       ;  Complement Read in Value so LEDs are on for "highs" 
  mov   P1,A                    ;  Store the Result in "A"

  ajmp  Loop

⌨️ 快捷键说明

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