单片机按下按钮A,LED灯亮。按下按钮B,LED灯灭。汇编

2024-12-01 20:22:10
推荐回答(1个)
回答1:

key1 equ p1.0
key2 equ p1.1
led equ p1.2
org 0
jmp main
main:
mov sp,#0x70

loop:
jb key1,l1

call DELAY10MS

jb key1,l1

clr led
l1:
jb key2,l2

call delay10ms

jb key2,l2

setb led

l2:
jmp loop

DELAY10MS: ;@11.0592MHz
PUSH 30H
PUSH 31H
MOV 30H,#18
MOV 31H,#230
NEXT:
DJNZ 31H,NEXT
DJNZ 30H,NEXT
POP 31H
POP 30H
RET