TREE EQU 20H
OUT EQU 21H
TST:
MOV DPTR,#DATS
MOV P2,#TREE
MOV R0,#0
MOV R2,#16
CPY:
CLR A
MOVC A,@A+DPTR
MOVX @R0,A
INC DPTR
INC R0
DJNZ R2,CPY
LCALL NOORDER
;遍历顺序为ABCDEFGHIJK。
DATS:
DB 0BH,41H,42H,43H
DB 44H,45H,46H,00H
DB 47H,48H,49H,00H
DB 4AH,4BH,00H,00H
NOORDER:
MOV DPH,#OUT
MOV DPL,#0
MOV R2,#0
CLR A
CLEAR:
MOVX @DPTR,A
INC DPTR
DJNZ R2,CLEAR
MOV P2,#TREE
MOV R0,#0
MOV DPH,#OUT
MOV DPL,#0
MOVX A,@R0
MOVX @DPTR,A
MOV R2,A
INC R0
INC DPTR
JZ ORDEND
NO1:
MOVX A,@R0
INC R0
JZ NO1
MOVX @DPTR,A
INC DPTR
DJNZ R2,NO1
ORDEND:
RET