prog7.asm

来自「包括了各种常用的8051单片机的程序」· 汇编 代码 · 共 39 行

ASM
39
字号
;  PROG7 - Accessing Bits
;
;  This Program Reads and Writes individual Bits in the Bit Addressable Area
;   of the Scractchpad RAM (Addresses 020 to 02F) and the I/O Ports.
;
;  This program will run in the UMPS simulator for a DS80C320.
;
;  Myke Predko
;  98.02.09
;
;  Hardware Notes:
;   This program is only meant to run on the Simulator
$define LED P1.0                ;  Virtual (real?) LED
$define Button P1.1             ;  Button which will be Used for LED

;  Variable Declarations
Bit1 EQU 7                      ;  Bit 7 of Address 020h
Bit2 EQU 9                      ;  Bit 1 of Address 021h

;  Mainline
 org 0                          ;  Execution Starts Here

  clr    Bit1                   ;  Reset/Set Bit 7 at Address 020h
  setb   Bit1

  clr    C                      ;  Clear the Carry Flag

  orl    C,Bit1                 ;  OR the Carry Flag With Bit1 and Save Result in Carry

  mov    Bit2,C                 ;  Save the
                                ;   To Initialize the Value for Later

Loop:                           ;  Loop Here Forever when Finished

  mov    C,P1.1                 ;  Read the Button Value
  mov    P1.0,C                 ;  If Pressed, Light the LED

  ajmp   Loop

⌨️ 快捷键说明

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