单片机的c语言,求答案。。。坐等,两个题的程序
发布网友
发布时间:2023-07-17 21:57
我来回答
共1个回答
热心网友
时间:2024-11-24 17:26
1:
CLRRAM:
MOV DPTR,#7000H
MOV R2,#0
LOOP:
CLR A
MOVX @DPR,A
INC DPTR
INC R2
CJNE R2,#0FFH,LOOP
RET
2:
BCDCHG:
MOV A,30H
ANL A,#0FH
CJNE A,#10,LP1
LP1:
JNC ERR
LP2:
PUSH ACC
MOV A,30H
SWAP A
ANL A,#0FH
MOV B,#10
MUL AB
MOV B,A
POP ACC
ADD A,B
CJNE A,#100,LP3
LP3:
JNC ERR
RTN:
MOV DPTR,#1000H
MOVX @DPTR,A
RET
ERR:
MOV A,#0FFH
SJMP RTN
3:
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV A,#0FEH
LOOP:
MOV P1,A
LCALL DELAY
RL A
SJMP LOOP
DELAY:
MOV R2,#5
DELAY1:
MOV R3,#126
DELAY2:
MOV R4,#200
DJNZ R4,$
DJNZ R3,DELAY2
DJNZ R2,DELAY1
RET
END