74ls138三八译码器,ABC分别接P1.0P1.1P1.2,Y0~Y7分别接0~7号数码管(共阴极),输出格式是: 23-59-59,你只用6个数码管,就把中间的两个横杠去掉就行了,代码修改一下。(不仅是代码中用于显示-的部分,还有数码管的控制字,也就是三八译码器的3个输入端得信号,也要去掉两个)。P2.0~P2.7接数码管的八位(P2.0接a,依次。。。)调整时间的用四个独立按键,控制时钟+的接P3.2,-的接P3.2,控制分钟+的接P1.0,-的接P1.1。这4个控制键可以自己改。源程序:COUNT1 EQU 30HMIAO1 EQU 31HMIAO2 EQU 32HCOUNT2 EQU 33HFEN1 EQU 34HFEN2 EQU 35HCOUNT3 EQU 36HSHI1 EQU 37HSHI2 EQU 38HORG 0000HSJMP STARTORG 0030HSTART:MOV SP,#60H MOV P0,#0FFH MOV P2,#0FFH MOV DPTR,#TAB MOV COUNT1,#0 MOV MIAO1,#0 MOV MIAO2,#0 MOV COUNT2,#0 MOV FEN1,#0 MOV FEN2,#0 MOV COUNT3,#0 MOV SHI1,#0 MOV SHI2,#0MAIN: CALL PROCESS1 CALL PROCESS2 CALL PROCESS3 CALL DISPLAY INC COUNT1 SJMP MAINPROCESS1:MOV A,COUNT1 CJNE A,#60,JIXU1 MOV COUNT1,#0 INC COUNT2 JIXU1: MOV A,COUNT1 MOV B,#10 DIV AB MOV MIAO1,A MOV MIAO2,B RETPROCESS2:MOV A,COUNT2 CJNE A,#60,JIXU2 MOV COUNT2,#0 INC COUNT3 JIXU2: MOV A,COUNT2 MOV B,#10 DIV AB MOV FEN1,A MOV FEN2,B RETPROCESS3:MOV A,COUNT3 CJNE A,#24,JIXU3 MOV COUNT3,#0 JIXU3: MOV A,COUNT3 MOV B,#10 DIV AB MOV SHI1,A MOV SHI2,B RETDISPLAY:MOV R2,#0FHL1: MOV R3,#09HL2: MOV A,MIAO1 MOVC A,@A+DPTR MOV P2,A MOV P1,#06H CALL DELAY MOV A,MIAO2 MOVC A,@A+DPTR MOV P2,A MOV P1,#07H CALL DELAY MOV P2,#40H MOV P1,#05H CALL DELAY MOV A,FEN1 MOVC A,@A+DPTR MOV P2,A MOV P1,#03H CALL DELAY MOV A,FEN2 MOVC A,@A+DPTR MOV P2,A MOV P1,#04H CALL DELAY MOV P2,#40H MOV P1,#02H CALL DELAY MOV A,SHI1 MOVC A,@A+DPTR MOV P2,A MOV P1,#00H CALL DELAY MOV A,SHI2 MOVC A,@A+DPTR MOV P2,A MOV P1,#01H CALL DELAY DJNZ R3,L2 DJNZ R2,L1 RETDELAY:MOV R0,#50D2: MOV R1,#10D1: DJNZ R1,D1 DJNZ R0,D2 RET