GRAPH EQU 20H TREE EQU 21H QUEUE EQU 1FH NODE EQU 30H FG EQU 40H POINT EQU 80H LENGTH EQU 40H D EQU 05H 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,#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 TST1: MOV DPH,#TREE 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,#TREE 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,#0 LCALL DATAIN MOV A,#0 LCALL DATAIN MOV A,K LCALL DATAIN LCALL BTREE INC K MOV A,K CJNE A,N,TEST1 STOP: LJMP STOP BTREE: MOV A,F XRL A,R JZ BFSEND LCALL DATAOUT MOV R4,A LCALL DATAOUT MOV R5,A LCALL DATAOUT MOV R2,A ADD A,#NODE MOV R0,A MOVX A,@R0 MOVX @DPTR,A MOV A,DPL CPL ACC.7 MOV DPL,A MOV A,R4 MOVX @DPTR,A MOV A,DPL CPL ACC.7 CPL ACC.6 MOV DPL,A MOV A,R5 MOVX @DPTR,A MOV A,DPL CPL ACC.6 MOV DPL,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 BTREE MOV R3,A ADD A,#FG MOV R0,A MOVX A,@R0 JNZ LOOPE MOV A,R2 LCALL DATAIN MOV A,R5 INC A LCALL DATAIN MOV A,R3 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