GRAPH EQU 20H QUEUE EQU 1FH OUT EQU 21H NODE EQU 30H FG EQU 40H D EQU 05H F DATA 3CH R DATA 3DH N DATA 3EH K DATA 3FH TEST: MOV SP,#5FH MOV DPTR,#GRA MOV P2,#GRAPH MOV R0,#0 MOV R2,#4AH CPY: CLR A MOVC A,@A+DPTR MOVX @R0,A INC DPTR INC R0 DJNZ R2,CPY MOV P2,#GRAPH MOV R0,#NODE MOVX A,@R0 JZ STOP INC A MOV N,A MOV K,#1 TEST1: 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,#NODE MOV DPH,#OUT MOV DPL,#0 MOVX A,@R0 MOVX @DPTR,A INC DPTR MOV R7,A MOV R0,#FG INC R0 CLRF: CLR A MOVX @R0,A INC R0 DJNZ R7,CLRF LCALL SETNULL MOV A,K LCALL DATAIN LCALL BFSL 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 BFSL: MOV A,F XRL A,R JZ BFSEND LCALL DATAOUT MOV R2,A ADD A,#NODE MOV R0,A MOVX A,@R0 MOVX @DPTR,A INC DPTR MOV A,R2 ADD A,#FG MOV R1,A MOV A,#0FFH MOVX @R1,A MOV A,R2 DEC A MOV B,#D MUL AB MOV R1,A LOOP: MOVX A,@R1 JZ BFSL MOV R2,A ADD A,#FG MOV R0,A MOVX A,@R0 JNZ LOOPE MOV A,R2 LCALL DATAIN MOV A,#1 MOVX @R0,A LOOPE: INC R1 LJMP LOOP 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: 02 08 00 00 00 ;2005H: 01 03 09 00 00 ;200AH: 02 04 06 00 00 ;200FH: 03 05 00 00 00 ;2014H: 04 06 07 00 00 ;2019H: 03 05 07 09 00 ;201EH: 05 06 08 00 00 ;2023H: 01 07 09 00 00 ;2028H: 02 06 08 00 00 ;2030H: 09 41 42 43 44 45 46 47 48 49 ;2040H: 00 00 00 00 00 00 00 00 00 00 GRA: DB 02H,08H,00H,00H DB 00H,01H,03H,09H DB 00H,00H,02H,04H DB 06H,00H,00H,03H DB 05H,00H,00H,00H DB 04H,06H,07H,00H DB 00H,03H,05H,07H DB 09H,00H,05H,06H DB 08H,00H,00H,01H DB 07H,09H,00H,00H DB 02H,06H,08H,00H DB 00H,00H,00H,00H DB 09H,41H,42H,43H DB 44H,45H,46H,47H DB 48H,49H,00H,00H END