STACK EQU 1FH BOTTOM EQU 00H TOP DATA 3EH TREE EQU 20H OUT EQU 21H TEST: MOV SP,#5FH MOV DPTR,#DATS MOV P2,#TREE MOV R0,#0 MOV R2,#32 COPY: CLR A MOVC A,@A+DPTR MOVX @R0,A INC DPTR INC R0 DJNZ R2,COPY 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 INC R0 INC DPTR JZ STOP MOV SP,#5FH LCALL SETNULL LCALL POST STOP: LJMP STOP DATS: DB 0BH,41H,42H,43H DB 44H,45H,46H,00H DB 47H,48H,49H,00H DB 4AH,4BH,00H,00H DB 0,0,0,0 DB 0,0,0,0 DB 0,0,0,0 DB 0,0,0,0 POST: MOVX A,@R0 JZ POSTEND MOV A,R0 JB ACC.7,POST1 LCALL DPUSH CLR C RLC A MOV R0,A LCALL POST LCALL DPOP LCALL DPUSH SETB C RLC A MOV R0,A LCALL POST LCALL DPOP MOV R0,A POST1: MOVX A,@R0 MOVX @DPTR,A INC DPTR POSTEND: RET SETNULL: MOV A,#BOTTOM MOV TOP,A RET DPUSH: INC TOP PUSH DPH PUSH DPL MOV DPH,#STACK MOV DPL,TOP MOVX @DPTR,A POP DPL POP DPH RET ;结束 DPOP: PUSH DPH PUSH DPL MOV DPH,#STACK MOV DPL,TOP MOVX A,@DPTR DEC TOP POP DPL POP DPH RET