编程,以“年/月/日 时:分:秒”的格式,显示当前的日期、时间
assume cs:code
data segment
db '2024/09/23 00:00:00','$'
data ends
code segment
start:
mov ax,data
mov es,ax
call get_hms_func
call get_ymd_func
mov dh,12 ;dh中存放行号
mov dl,24 ;dl中存放列
mov bh,0 ;第0页
mov ah,2 ;10h号中断的2号子程序
int 10h
mov ax,data
mov ds,ax
mov dx,0 ;指向需要显示的字符串,以$作为结束符
mov ah,9 ;功能号9,表示在光标位置显示字符串
int 21h
mov ax,4c00h
int 21h
get_hms_func:
mov dl,0
mov di,17
mov cx,3
push cx
push bx
push dx
push di
push ax
get_hms:
mov al,dl
out 70h,al
in al,71h
mov ah,al
push cx
mov cl,4
shr ah,cl
pop cx
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[di],ah
mov byte ptr es:[di+1],al
sub di,3
add dl,2
loop get_hms
get_hms_ret:
pop ax
pop di
pop dx
pop bx
pop cx
ret
get_ymd_func:
mov di,8
mov dl,7
mov cx,3
push cx
push bx
push dx
push di
push ax
get_ymd:
mov al,dl
out 70h,al
in al,71h
mov ah,al
push cx
mov cl,4
shr ah,cl
pop cx
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[di],ah
mov byte ptr es:[di+1],al
sub di,3
inc dl
loop get_ymd
get_ymd_ret:
pop ax
pop di
pop dx
pop bx
pop cx
ret
code ends
end start