并方便操作。(实验箱有4个LED显示管)
以前在网上见到个实例,是显示一个时钟的代码。 能正常显示。大家试试看。 DATA SEGMENT
DISPLAY DB ? MSG DB "PRESS 'ESC' TO EXIT...",10H,13H BKCOLOR DW 6D6DH MCOLOR DW 0030H SCOLOR DW 0028H MEM DW ? NUBTBL DB 1, 1, 1, 0, 1, 1, 1 ; 0 DB 0, 0, 1, 0, 0, 1, 0 ; 1 DB 1, 0, 1, 1, 1, 0, 1 ; 2 DB 1, 0, 1, 1, 0, 1, 1 ; 3 DB 0, 1, 1, 1, 0, 1, 0 ; 4 DB 1, 1, 0, 1, 0, 1, 1 ; 5 DB 1, 1, 0, 1, 1, 1, 1 ; 6 DB 1, 0, 1, 0, 0, 1, 0 ; 7 DB 1, 1, 1, 1, 1, 1, 1 ; 8 DB 1, 1, 1, 1, 0, 1, 1 ; 9 PTSEG DW 7,2,35,10 DW 2,7,10,35 DW 32,7,40,35 DW 7,32,35,40 DW 2,37,10,65 DW 32,37,40,65 DW 7,62,35,70
DATA ENDS
CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX MOV AX,0A000H MOV ES,AX
MOV AH,0FH INT 10H MOV DISPLAY,AL ;save display
MOV AX,0013H INT 10H ;set display
CLD MOV AX,BKCOLOR XOR DI,DI MOV CX,08000H REP STOSW _WAIT: MOV AH,2CH INT 21H ;read time
PUSH CX PUSH DX CALL MYTIME
MOV AH,1 INT 16H ;read buffer of keyboard
PUSH AX MOV DL,0FFH MOV AX,0C06H ;clear keyboard buffer INT 21H
POP AX SUB AL,1BH JNZ _WAIT
MOV AL,DISPLAY MOV AH,00 INT 10H ;resume the model of displing
MOV AX,4C00H INT 21H ;return to dos
;************* End Of Main() *************************
;------------ my three process --------------------- ;------------ proc 0: MYTIME PROC NEAR PASCAL USES AX BX CX DX DI SI, hm:word,sec:word MOV CX,HM ;hour XOR AX,AX MOV AL,CH AAM PUSH AX MOV CL,8 SHR AX,CL MOV DX,20 PUSH DX MOV DX,50 PUSH DX PUSH MCOLOR PUSH AX CALL DISPLAYDIGIT
POP AX AND AX,0FH MOV DX,62 PUSH DX MOV DX,50 PUSH DX PUSH MCOLOR PUSH AX CALL DISPLAYDIGIT MOV CX,HM ;mintute XOR AX,AX MOV AL,CL AAM PUSH AX MOV CL,8 SHR AX,CL MOV DX,116 PUSH DX MOV DX,50 PUSH DX PUSH MCOLOR PUSH AX CALL DISPLAYDIGIT
POP AX AND AX,0FH MOV DX,158 PUSH DX MOV DX,50 PUSH DX PUSH MCOLOR PUSH AX CALL DISPLAYDIGIT MOV CX,SEC ;second XOR AX,AX MOV AL,CH AAM PUSH AX MOV CL,8 SHR AX,CL MOV DX,212 PUSH DX MOV DX,50 PUSH DX PUSH SCOLOR PUSH AX CALL DISPLAYDIGIT
POP AX AND AX,0FH MOV DX,254 PUSH DX MOV DX,50 PUSH DX PUSH SCOLOR PUSH AX CALL DISPLAYDIGIT
RET MYTIME ENDP
;------------ proc 1: DISPLAYDIGIT PROC NEAR PASCAL USES AX BX CX DX DI SI, x:word,y:word,color:word,num:word LEA SI,NUBTBL MOV BX,7 MOV AX,NUM MUL BX ADD SI,AX ;choise a number LEA DI,PTSEG XOR CX,CX _FOR: MOV BX,BKCOLOR CMP BYTE PTR DS:[SI],0 JE DISPL MOV BX,COLOR DISPL: MOV DX,X ADD DX,DS:[DI] PUSH DX
MOV DX,Y ADD DX,DS:[DI+2] PUSH DX
MOV DX,X ADD DX,DS:[DI+4] PUSH DX
MOV DX,Y ADD DX,DS:[DI+6] PUSH DX PUSH BX CALL DRAWSIXGON
INC SI ADD DI,8 INC CX CMP CX,7 JNE _FOR
RET DISPLAYDIGIT ENDP
;------------ proc 2: DRAWSIXGON PROC NEAR PASCAL USES AX BX CX DX DI SI, startX:word,startY:word,endX:word,endY:word,color:word LOCAL FLAG:WORD
MOV FLAG,1 MOV BX,STARTX MOV SI,STARTY MOV AX,320 MUL SI ADD AX,BX MOV MEM,AX ;mem=320*startY+startX MOV AX,ENDY SUB AX,STARTY MOV DX,ENDX SUB DX,STARTX MOV CX,DX
CMP AX,DX JC DRAW MOV FLAG,320 ;direct MOV CX,AX DRAW: XOR BX,BX XOR SI,SI MOV DX,3 MOV BX,COLOR SUB CX,8 ;length of line - 8 PUSH CX ABOVE: MOV DI,SI ;retive point of starting PUSH DX MOV AX,FLAG MUL DX POP DX ADD SI,AX ADD SI,MEM @@1: MOV BYTE PTR ES:[SI],BL ADD SI,FLAG ;next pix DEC CX ;bx-->next line JNZ @@1 POP CX ADD CX,2 PUSH CX CMP FLAG,1 JNE @@2 ADD DI,320 JMP $+3 @@2: INC DI MOV SI,DI ;next line DEC DX JNZ ABOVE DOWN: MOV DI,SI ;retive point of starting PUSH DX MOV AX,FLAG MUL DX POP DX ADD SI,AX ADD SI,MEM @@3: MOV BYTE PTR ES:[SI],BL ADD SI,FLAG DEC CX JNZ @@3 POP CX SUB CX,2 PUSH CX CMP FLAG,1 JNE @@4 ADD DI,320 JMP $+3 @@4: INC DI MOV SI,DI INC DX CMP DX,4 JNZ DOWN
POP CX RET
DRAWSIXGON ENDP
CODE ENDS END START