单片机小的编程,编了下不知道对不对!望大家指正谢谢!

2024-11-24 17:44:17
推荐回答(2个)
回答1:

修改了错误,增加了原始数据,如下所示。
ORG 0000H
SJMP MAIN
ORG 0050H
MAIN:

;01H 23H 45H 67H 89H 0ABH 0CDH 0EFH
MOV 30H, #01H
MOV 31H, #23H
MOV 32H, #45H
MOV 33H, #67H
MOV 34H, #89H
MOV 35H, #0ABH
MOV 36H, #0CDH
MOV 37H, #0EFH

MOV R2, #8
MOV R0, #30H ;是30,不是20
MOV R1, #40H ;是40, 不是30
MOV DPTR, #ASCTB
LOOP:
MOV A, @R0
ANL A, #0F0H
SWAP A
ACALL TRANS
MOV A, @R0
ANL A, #0FH ;是0F,不是F0
ACALL TRANS
INC R0
DJNZ R2, LOOP
SJMP $

TRANS:
MOVC A, @A+DPTR
MOV @R1, A
INC R1
RET

ASCTB: DB 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
DB 41H,42H,43H,44H,45H,46H

END

回答2:

修改了错误,增加了原始数据,如下所示。
ORG
0000H
SJMP
MAIN
ORG
0050H
MAIN:
;01H
23H
45H
67H
89H
0ABH
0CDH
0EFH
MOV
30H,
#01H
MOV
31H,
#23H
MOV
32H,
#45H
MOV
33H,
#67H
MOV
34H,
#89H
MOV
35H,
#0ABH
MOV
36H,
#0CDH
MOV
37H,
#0EFH
MOV
R2,
#8
MOV
R0,
#30H
;是30,不是20
MOV
R1,
#40H
;是40,
不是30
MOV
DPTR,
#ASCTB
LOOP:
MOV
A,
@R0
ANL
A,
#0F0H
SWAP
A
ACALL
TRANS
MOV
A,
@R0
ANL
A,
#0FH
;是0F,不是F0
ACALL
TRANS
INC
R0
DJNZ
R2,
LOOP
SJMP
$
TRANS:
MOVC
A,
@A+DPTR
MOV
@R1,
A
INC
R1
RET
ASCTB:
DB
30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
DB
41H,42H,43H,44H,45H,46H
END