【DOS编程】简单显示当前日期、时间
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;
;;INT 7CH , A simple code used to display the current time&data. ;;
;; BY 13*02172014-12-4 ;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
assume cs:codesg
codesg segment
start:mov ax,cs
mov ds,ax
mov si,offset do0
mov ax,0h
mov es,ax
mov di,200h
mov cx,offset do0ends - offset do0
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:,200h
mov word ptr es:,0h
mov ax,4c00h
int 21h
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;
;; The interrupt type code named 7ch,CPU could call its process. ;
;; The interrupt fuction maybe needs color. ;
;; the time format:xx year-yy month-zz day && qq time-ww minute-ee second. ;
;; It would be display the time information in the center of screen that we want do. ;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;
do0:jmp short do0start
db 'yy/mm/dd tt:mm:ss ',0,0
s:db 9,8,7,4,2,0
do0start:mov ax,cs
mov ds,ax
mov si,202h
mov di,216h
_x:mov cx,ds:
jcxz ok
mov al,ds:
out 70h,al
inal,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr ds:,ah
mov byte ptr ds:,al
add si,3h
inc di
jmp short _x
ok:call show_str
iret
show_str:mov ax,0b800h
mov es,ax
mov si,202h
sub di,di
mov dx,0c22h ; The time would be displayed in the position.
mov al,0a0h
mul dh
add di,ax
mov al,2h
mul dl
add di,ax
_str:mov cx,ds:
jcxz ui
mov es:,cl
mov es:,bl
add di,2h
inc si
jmp short _str
ui:ret
do0ends:nop
codesg ends
end start
附上一段测试代码:
assume cs:codesg
codesg segment
start:mov ax,0003h
int 10h
mov bl,04h
int 7ch
mov ax,4c00h
int 21h
codesg ends
end start
页:
[1]