要求
输出系统的时间包括:时-分;星期;年-月-日
一、程序
DATAS SEGMENT
;此处输入数据段代码
a1 db 'Sun','Mon','Tue','Wed','Thur','Fri','Sat'
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;此处输入代码段代码
;hour
mov al,4
out 70h,al
in al,71h
mov ah,0
call output
mov al,':'
call dispc
;min
mov al,2
out 70h,al
in al,71h
mov ah,0
call output
call control
;week
mov al,6
out 70h,al
in al,71h
mov ah,0
call output1
call control
;year
mov al,9
out 70h,al
in al,71h
mov ah,0
call output
mov al,'-'
call dispc
;month
mov al,8
out 70h,al
in al,71h
mov ah,0
call output
mov al,'-'
call dispc
;day
mov al,7
out 70h,al
in al,71h
call output
MOV AH,4CH
INT 21H
output proc ;ax为入口参数
push bx
push cx
push ax
push dx
mov cl,16
mov bl,0
D1:
cmp al,0
je D2
div cl
push ax
add bl,1
mov ah,0
jmp D1
D2:
cmp bl,0
je dover
pop cx
sub bl,1
mov dl,ch
add dl,48
mov ah,2
int 21h
jmp D2
dover:
pop dx
pop ax
pop cx
pop bx
ret
output endp
;回车换行
dispc proc
push ax
push dx
mov dl,al
mov ah,2
int 21h
pop dx
pop ax
ret
dispc endp
;输出星期
output1 proc
push ax
push dx
push si
mov si,offset a1
mov dl,0
sub al,1
L0:
cmp dl,al
jb L1
mov dl,[si]
mov ah,2
int 21h
add si,1
mov dl,[si]
mov ah,2
int 21h
add si,1
mov dl,[si]
mov ah,2
int 21h
jmp L3
L1:
add si,3
add dl,1
jmp L0
L3:
pop si
pop dx
pop ax
ret
output1 endp
;输出字符
control proc
push ax
push dx
mov dl,13
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
pop dx
pop ax
ret
control endp
CODES ENDS
END START