📄 showtim2.asm
字号:
;显示系统当前日期和时间的问题,程序编译和连接没问题 ,
;只是达不到显示日期时间的功能 全是乱码,请求各位能给予帮
;内容:显示系统当前日期和时间
;设计思路:
;利用dos系统功能调用2AH 和 2CH功能调用读取系统日期和时间
;将日期和时间的值转换成相应的ASCⅡ码字符 显示在屏幕上
;说明:
;直接在操作系统状态下 双击可执行程序fan.exe
;输入d可显示窗口 输入t显示时间 输入q可返回操作系统
stack1 segment stack
dw 200 dup(?)
stack1 ends
data segment
space db 1000 dup(0)
db 0bcH,6 dup(0)
dbuffer1 db 20 dup(0)
dbuffer db 8 dup(':'), 12 dup(0)
str1 db 0dh,0ah,'please input data(d), time(t) or'
db 'quit(q):','$'
;time(t)
data ends
code segment
assume cs:code,ds:data,ss:stack1
start:
mov ax,0002h ;设置显示方式;为80*25 16彩色文本方式
int 10h
mov ax, data ;*
mov ds,ax
mov es,ax
mov bp,offset space
mov dx,0b00h
mov cx,1000
mov bx,0040h
mov ax,1300h
int 10h
mov dx,0b00h
mov cx,120
mov bx,004eh
mov ax,1301h
int 10h
;AH=13H 在Teletype模式下显示字符串
;BH=页码
;BL=属性(若AL=00H或01H)
;CX=显示字符串长度
;(DH、DL)=坐标(行、列)
;ES:BP=显示字符串的地址 AL= 显示输出方式
;0——字符串中只含显示字符,其显示属性在BL中。显示后,光标位置不变
; 1——字符串中只含显示字符,其显示属性在BL中。显示后,光标位置改变
; 2——字符串中含显示字符和显示属性。显示后,光标位置不变
;3——字符串中含显示字符和显示属性。显示后,光标位置改变
;mov bp,offset Pattern ;显示矩形条
lea dx,str1
mov ah,9 ;显示提示信息
int 21h
mov ah,1 ;从键盘输入单个字符
int 21h
cmp al,64h;al='d'? ;*
jne atime ;*
call data1 ;显示系统日期
jmp start ;*
atime:
cmp al, 74h ;al='t'?
jne j_a
call time1
jmp start
j_a:
cmp al,71h ;al='q'? ;*
jne start
mov ah,4ch
int 21h
data1 proc near ;显示日期子程序
display:
mov ah,2ah ;取日期 出口参数: CX=年(1980~2099),DH=月(1~12),DL=日(1~31)
int 21h ;AL=星期几(0=Sunday,1=Monday,...)
mov si,0
mov ax,cx
mov bx,100
div bl ; al,商,ah余数
mov bl,ah
call bcdasc1 ; 日期数值转换成相应的 ASCⅡ码
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, 10
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
;dll bx
dec bx
;int repea
jnz repea ;*
mov ah,01h ;* 读键盘缓冲区字符到al
int 16h
je display ;*
jmp start
mov ax,4c00h
int 21h
ret
data1 endp
time1 proc near
display1:
mov si,0 ;显示时间子程序
mov bx,100
div bl
mov ah,2ch ;取时间
int 21h
mov al,ch
call bcdasc ;将时间数值转换成ASCv2Ⅱ码
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
mov cx,0ffffh
rea:
loop rea
dec bx
jnz rea
mov ah,01h ;*
int 16h
je display1
jmp start
mov ax,4c00h
int 21h
ret
time1 endp
bcdasc proc near ;**将时间数值转换成ASCv2Ⅱ码
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
bcdasc1 proc near
push bx
cbw ;CBW(Convert byte to word)字节转换为字 al->ax
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
code ends
end start
;'不耻下问' ? 知道 '不耻下问' 是什么意思么?!
;上面的那个帖子里的代码没有仔细看你的要求, 就直接按照你的流程改的, 这个是更完善些的
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -