📄 2402.asm
字号:
wp equ p1.0
scl equ p1.1
sda equ p1.2
RELAY EQU P1.3
red equ p1.4
green equ p1.5
bell equ p1.6
key_open equ p1.7
addr equ 31h
data8 equ 32h
org 0
JMP READ_DATA
ORG 0030H
READ_DATA:mov sp,#6fh
;CLR BELL
;CLR RED
;CLR GREEN
;CLR RELAY
MOV ADDR,#00h
MOV DATA8,#0h
MOV A,#5
mov r7,#00h
READ_DATA1:clr wp
lcall del_10ms
LCALL WR_DATA
lcall del_10ms
MOV R6,A
INC ADDR
inc data8
DJNZ R7,READ_DATA1
lcall del_10ms
setb wp
jmp $
wr_data:lcall bstart ;写程序
;LCALL DELAY
mov a,#0a0h
;LCALL DELAY
lcall wbyte
mov a,addr
lcall wbyte
;LCALL DELAY
;clr wp
lcall del_10ms
mov a,data8
lcall wbyte
;inc data8
;djnz r7,ff
;setb wp
lcall bstop
ret
rd_data:lcall bstart ;读程序
mov a,#0a0h
lcall wbyte
mov a,addr
lcall wbyte
lcall delay
lcall bstart
mov a,#0a1h
lcall wbyte
lcall rbyte
lcall bstop
ret
delay:nop
NOP
NOP
NOP
NOP
NOP
NOP
ret
bstart:clr scl ;启动条件
lcall delay
setb sda
lcall delay
setb scl
clr sda
lcall delay
clr scl
ret
bstop:clr scl;停止条件
lcall delay
clr sda
lcall delay
setb scl
lcall delay
setb sda
lcall delay
clr scl
lcall delay
ret
wbyte:LCALL DELAY
mov r2,#8 ;字节写程序
;clr wp
lcall delay
LCALL DELAY
CLR C
wby0:clr scl
LCALL DELAY
rlc a
LCALL DELAY
mov sda,c
LCALL DELAY
setb scl
;clr scl
LCALL DELAY
djnz r2,wby0
LCALL DELAY
;lcall delay
clr scl
lcall delay
setb scl
lcall delay
;jnb sda,$
;LCALL DELAY
rep: mov c,sda
Jc rep
clr scl
lcall delay
;setb wp
ret
rbyte:lcall delay
mov r2,#8
rby0:lcall delay
setb scl
lcall delay
mov c,sda
rlc a
clr scl
djnz r2,rby0
clr scl
lcall delay
setb sda
lcall delay
setb scl
lcall delay
ret
wbyte1:LCALL DELAY
mov r2,#8 ;字节写程序
;clr wp
lcall delay
CLR C
wby01:clr scl
rlc a
LCALL DELAY
mov sda,c
LCALL DELAY
setb scl
clr scl
LCALL DELAY
djnz r2,wby01
LCALL DELAY
;lcall delay
clr scl
lcall delay
setb scl
LCALL DELAY
rep1: mov c,sda
Jc rep1
clr scl
lcall delay
;setb wp
ret
DELAY1:MOV R4,#0
DEL1:MOV R5,#100
DEL2:DJNZ R5,DEL2
DJNZ R4,DEL1
RET
del_10MS:MOV R4,#5
LOOP1:MOV R3,#0F9H
LOOP2:NOP
NOP
DJNZ R3,LOOP2
DJNZ R4,LOOP1
RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -