GRAPH EQU 20H OUT EQU 21H QUEUE EQU 1FH F DATA 3CH R DATA 3DH N DATA 3EH K DATA 3FH TST: MOV SP,#5FH MOV DPTR,#GRA MOV P2,#GRAPH MOV R0,#0 MOV R2,#0A0H CPY: CLR A MOVC A,@A+DPTR MOVX @R0,A INC DPTR INC R0 DJNZ R2,CPY MOV P2,#GRAPH MOV R0,#0 MOVX A,@R0 JZ STOP INC A MOV N,A MOV K,#1 TST1: MOV DPH,#OUT MOV DPL,#0 MOV R2,#0 CLR A CLEAR: MOVX @DPTR,A INC DPTR DJNZ R2,CLEAR MOV P2,#GRAPH MOV R0,#0 MOV DPH,#OUT MOV DPL,#0 MOVX A,@R0 MOVX @DPTR,A MOV R7,A INC DPTR MOV R0,#10H CLRF: CLR A MOVX @R0,A MOV A,#10H ADD A,R0 MOV R0,A JNZ CLRF LCALL SETNULL MOV A,K LCALL DATAIN LCALL BFS INC K MOV A,K CJNE A,N,TEST1 STOP: LJMP STOP ;出发点为1时的遍历顺序:ABHCIGDFE ;出发点为2时的遍历顺序:BACIHDFGE ;出发点为3时的遍历顺序:CBDFAIEGH ;出发点为4时的遍历顺序:DCEBFGAIH ;出发点为5时的遍历顺序:EDFGCIHBA ;出发点为6时的遍历顺序:FCEGIBDHA ;出发点为7时的遍历顺序:GEFHDCIAB ;出发点为8时的遍历顺序:HAGIBEFCD ;出发点为9时的遍历顺序:IBFHACEGD BFS: MOV A,F XRL A,R JZ BFSEND LCALL DATAOUT MOV R0,A MOVX A,@R0 MOVX @DPTR,A INC DPTR MOV A,R0 SWAP A MOV R1,A MOV A,#0FFH MOVX @R1,A INC R1 MOV A,R7 MOV R6,A LOOP: MOVX A,@R1 JZ LOOPE MOV A,R1 ANL A,#0FH MOV R2,A SWAP A MOV R0,A MOVX A,@R0 JNZ LOOPE MOV A,R2 LCALL DATAIN MOV A,#1 MOVX @R0,A LOOPE: INC R1 DJNZ R6,LOOP LJMP BFS BFSEND: RET SETNULL: MOV A,#0FFH MOV F,A MOV R,A RET DATAIN: PUSH DPH PUSH DPL INC R MOV DPL,R MOV DPH,#QUEUE MOVX @DPTR,A POP DPL POP DPH RET DATAOUT: PUSH DPH PUSH DPL INC F MOV DPL,F MOV DPH,#QUEUE MOVX A,@DPTR POP DPL POP DPH RET ;2000H: 09 41 42 43 44 45 46 47 48 49 ;2010H: 00 00 01 00 00 00 00 00 01 00 ;2020H: 00 01 00 01 00 00 00 00 00 01 ;2030H: 00 00 01 00 01 00 01 00 00 00 ;2040H: 00 00 00 01 00 01 00 00 00 00 ;2050H: 00 00 00 00 01 00 01 01 00 00 ;2060H: 00 00 00 01 00 01 00 01 00 01 ;2070H: 00 00 00 00 00 01 01 00 01 00 ;2080H: 00 01 00 00 00 00 00 01 00 01 ;2090H: 00 00 01 00 00 00 01 00 01 00 GRA: DB 09H,41H,42H,43H DB 44H,45H,46H,47H DB 48H,49H,00H,00H