汇编程序:电子日历时钟系统程序设计
发布网友
发布时间:2022-05-13 19:28
我来回答
共2个回答
热心网友
时间:2023-08-15 07:32
STACK SEGMENT STACK
DW 200 DUP (?)
STACK ENDS
DATA SEGMENT
WHOUR DB 0 ;秒表的时、分、秒、毫秒
WMIN DB 0
WSEC DB 0
WMSEC DB 0
OLD1CH DD 0
SIGNAL DB 0
COUNT DW 0
;---------------------------------------------------------------------------------------------------------------
CHOUR DB 0 ;闹钟的时、分、秒
CMIN DB 0
CSEC DB 0
;-----------------------------------------------------------------------------------------------------------------
SPACE DB 2000 DUP (' ')
PATTERN DB 6 DUP (' '),0C9H,26 DUP (0CDH),0BBH,6 DUP (' ')
DB 6 DUP (' '),0BAH,26 DUP (20H),0BAH,6 DUP (' ')
DB 6 DUP (' '),0C8H,26 DUP (0CDH),0BCH,6 DUP (' ')
;----------------------------------------------------------------------------------------------------------------
DBUFFER DB 8 DUP (':'),12 DUP (' ')
DBUFFER1 DB 20 DUP (' ')
DBUFFER2 DB 11 DUP (':'),15 DUP (' ')
STR DB 0DH,0AH, ' INPUT ''M'' TO NEXT-STATE, INPUT ''Q'' TO EXIT: $',0DH,0AH,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACK
;-------------------------------------------------------------------
PUSHA MACRO
PUSH DS
PUSH AX
PUSH BX
PUSH CX
PUSH DX
ENDM
POPA MACRO
POP DX
POP CX
POP BX
POP AX
POP DS
ENDM
;图形化界面设计
START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV AX,0003H ;设置显示方式为40*25彩色文本方式
INT 10H
LEA DX,STR ;显示提示信息
MOV AH,9
INT 21H
MOV BP,OFFSET SPACE
MOV DX,0B00H
MOV CX,1000
MOV BX,0000H
MOV AX,1300H
INT 10H ;显示字符串,定义显示方式
;---------------------------------------------------------------
;主程序
LP1:
MOV AH,1 ;从键盘输入单个字符
INT 21H
CMP AL,'M' ;AL='M'?
JNE LP5
CALL DATE ;显示系统日期
LP2: MOV AH,1 ;从键盘输入单个字符
INT 21H
CMP AL,'M' ;AL='M'?
JNE LP5
CALL TIME ;显示系统时间
LP3: MOV AH,1 ;从键盘输入单个字符
INT 21H
CMP AL,'M' ;AL='M'?
JNE LP4
CALL STOPWATCH ;显示秒表
LP4: MOV AH,1 ;从键盘输入单个字符
INT 21H
CMP AL,'M' ;AL='M'?
JNE LP5
CALL RING
LP5: CMP AL,'Q' ;AL='Q'?
JNE LP1
MOV AH,4CH ;返回DOS状态
INT 21H
;---------------------------------------------------------------
;显示日期子程序
DATE PROC NEAR
DISPLAY:
MOV AH,2AH ;取日期CX:DH:DL=年:月:日 AL=星期
INT 21H
MOV SI,0
MOV AX,CX
MOV BX,100
DIV BL
MOV BL,AH
CALL BCDASC1 ;日期数值转换成相应的ASCII码字符
MOV AL,BL
CALL BCDASC1
INC SI
MOV AL,DH
CALL BCDASC1
INC SI
MOV AL,DL
CALL BCDASC1
MOV BP,OFFSET DBUFFER1
MOV DX,0C0DH
MOV CX,20
MOV BX,004EH
MOV AX,1301H
INT 10H
MOV AH,02H ;设置光标位置
MOV DX,0300H
MOV BH,0
INT 10H
MOV BX,0018H
REPEA:MOV CX,0FFFFH ;延时
REPEAT:LOOP REPEAT
DEC BX
JNZ REPEA
MOV AH,01H ;读键盘缓冲区字符到AL寄存器
INT 16H
JE DISPLAY
JMP LP2
MOV AX,4C00H
INT 21H
RET
DATE ENDP
;------------------------------------------------------
;显示时间子程序
TIME PROC NEAR
DISPLAY1:
MOV SI,0
MOV BX,100
DIV BL
MOV AH,2CH ;取时间CH:CL=时:分 DH:DL=秒:1/100秒
INT 21H
MOV AL,CH
CALL BCDASC ;将时间数值转换成ASCII码字符
INC SI
MOV AL,CL
CALL BCDASC
INC SI
MOV AL,DH
CALL BCDASC
MOV BP,OFFSET DBUFFER
MOV DX,0C0DH
MOV CX,20
MOV BX,004EH
MOV AX,1301H
INT 10H
MOV AH,02H
MOV DX,0300H
MOV BH,0
INT 10H
MOV BX,0018H
RE: MOV CX,0FFFFH
REA: LOOP REA
DEC BX
JNZ RE
MOV AH,01H
INT 16H
JE DISPLAY1
JMP LP3
MOV AX,4C00H
INT 21H
RET
TIME ENDP
;------------------------------------------------------
;显示秒表子程序
STOPWATCH PROC NEAR
DISPLAY2:
PUSHA
MOV SI,0
MOV BX,100
DIV BL
;CALL WATCH
DISP3:
MOV AX,DATA
MOV DS,AX
MOV AL,WHOUR
CALL BCDASC2 ;将时间数值转换成ASCII码字符
INC SI
MOV AL,WMIN
CALL BCDASC2
INC SI
MOV AL,WSEC
CALL BCDASC2
MOV AL,WMSEC
INC SI
CALL BCDASC2
MOV BP,OFFSET DBUFFER2
MOV DX,0C0DH
MOV CX,20
MOV BX,004EH
MOV AX,1301H
INT 10H
MOV AH,02H
MOV DX,0300H
MOV BH,0
INT 10H
MOV BX,0018H
RE2: MOV CX,0FFFFH
REA2: LOOP REA2
DEC BX
JNZ RE2
MOV AH,01H
INT 16H
JE DISPLAY2
POPA
JMP LP4
MOV AX,4C00H
INT 21H
RET
STOPWATCH ENDP
;----------------------------------------------------------------
;显示闹钟子程序
RING PROC NEAR
DISPLAY3:
PUSHA
MOV SI,0
MOV BX,100
DIV BL
;MOV AH,CH ;取时间CH:CL=时:分 DH:DL=秒:1/100秒
;INT 21H
MOV AX,DATA
MOV DS,AX
MOV AL,CHOUR
CALL BCDASC ;将时间数值转换成ASCII码字符
INC SI
MOV AL,CMIN
CALL BCDASC
INC SI
MOV AL,CSEC
CALL BCDASC
MOV BP,OFFSET DBUFFER
MOV DX,0C0DH
MOV CX,20
MOV BX,004EH
MOV AX,1301H
INT 10H
MOV AH,02H
MOV DX,0300H
MOV BH,0
INT 10H
MOV BX,0018H
RE3: MOV CX,0FFFFH
REA3: LOOP REA3
DEC BX
JNZ RE3
MOV AH,01H
INT 16H
JE DISPLAY3
POPA
JMP START
MOV AX,4C00H
INT 21H
RET
RING ENDP
;----------------------------------------------------------------
;时间数值转换成ASCII码字符子程序
BCDASC PROC NEAR
PUSH BX
CBW
MOV BL,10
DIV BL
ADD AL,'0'
MOV DBUFFER[SI],AL
INC SI
ADD AH,'0'
MOV DBUFFER[SI],AH
INC SI
POP BX
RET
BCDASC ENDP
;-----------------------------------------------------------------
;日期数值转换成ASCII码字符子程序
BCDASC1 PROC NEAR
PUSH BX
CBW
MOV BL,10
DIV BL
ADD AL,'0'
MOV DBUFFER1[SI],AL
INC SI
ADD AH,'0'
MOV DBUFFER1[SI],AH
INC SI
POP BX
RET
BCDASC1 ENDP
;------------------------------------------------------------------
;秒表时间数值转换成ASCII码字符子程序
BCDASC2 PROC NEAR
PUSH BX
CBW
MOV BL,10
DIV BL
ADD AL,'0'
MOV DBUFFER2[SI],AL
INC SI
ADD AH,'0'
MOV DBUFFER2[SI],AH
INC SI
POP BX
RET
BCDASC2 ENDP
;---------------------------------------------------------------------
CODE ENDS
END START
只有主要功能,刚把完整的给你发到邮箱里了
热心网友
时间:2023-08-15 07:33
不好意思三天时间不够