📄 huibian.asm
字号:
;作者:计算机03级6班 赵国涛 许军军 刘周刚 合作完成
; 庆祝我们的成功!cheers!!!!!!!!!!!!!!!!!!!!!!!!!:-o
STACK SEGMENT STACK
DW 200 DUP (?)
STACK ENDS
DATA SEGMENT
SPACE DB 1000 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 (' ')
DBUFFER1 DB 8 DUP (':'),12 DUP (' ')
DBUFFER DB 20 DUP (' ')
STR DB 0DH,0AH, 'PLEASE INPUT DATE(D) OR TIME(T) OR QUIT(Q): $'
mon db 'MONDAY '
tues db 'TUESDAY '
wend db 'WEDNESDAY' ;占9byte
thur db 'THURSDAY '
fri db 'FRIDAY '
satu db 'SATURDAY '
sun db 'SUNDAY '
prompt db 0dh,0ah,'input wrong!!!,please try again!',0dh,0ah,'$'
minsize dw ? ;控制输出
pp db ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACK
START: MOV AX,0001H
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 BP,OFFSET PATTERN ;显示矩形条
MOV DX,0B00H
MOV CX,120
MOV BX,004EH
MOV AX,1301H
INT 10H
again: LEA DX,STR ;显示提示信息
MOV AH,9
INT 21H
mov ah,1
int 21h
cmp al,44h
jne small_d
call date
small_d:
cmp al,64h
jne big_t
call date
big_t:
cmp al,54h
jne small_t
call time
small_t:
cmp al,74h
jne big_q
call time
big_q:
cmp al,51h
jne small_q
jmp exit
small_q:
cmp al,71h
jne try
jmp exit
try:
mov dx,offset prompt
mov ah,9
int 21h
jmp again
exit:
mov ah,4ch
int 21h ;the main part come here
date proc near
mov [minsize],2 ; 结果总是至少两个数字
mov [pp], '0' ;为了转变成字符
mov ah,2ah
int 21h
lea di,dbuffer
push ax ;store weekday in al
mov ax,cx ; get year
call compute
mov byte ptr [di],'/'
inc di
xor ax,ax ;month
mov al,dh
call compute
mov byte ptr [di],'/'
inc di
xor ax,ax ;day
mov al,dl
call compute
mov byte ptr [di],'/'
inc di
pop ax
mov cx,9
cld
cmp al,0 ; output the current weekday
jne t11
lea si,sun
rep movsb
jmp result
t11: cmp al,1
jne t22
lea si,mon
rep movsb
jmp result
t22:
cmp al,2
jne t33
lea si,tues
rep movsb
jmp result
t33:
cmp al,3
jne t44
lea si,wend
rep movsb
jmp result
t44:
cmp al,4
jne t55
lea si,thur
rep movsb
jmp result
t55:
cmp al,5
jne t66
lea si,fri
rep movsb
jmp result
t66:
lea si,satu
rep movsb
result:
lea bp,dbuffer ;output the date result
mov ax,1301h
mov cx,20
mov bx,0090h
mov dx,0c08h
int 10h
wait1:
mov ah,2 ;wait input again
mov dx,1004h
int 10h
mov ah,1
int 16h
je wait1
jmp start
mov ah,4ch
int 21h
date endp
time proc near
continue:
mov [minsize],2
mov [pp],'0'
mov ah,2ch
int 21h
lea di,dbuffer1
xor ax,ax
mov al,ch ;hour
call compute
inc di
mov al,cl ;minute
call compute
inc di
mov al,dh ;second
call compute
lea bp,dbuffer1
mov ax,1301h
mov cx,20
mov bx,0090h
mov dx,0c08h
int 10h
mov ah,2
mov dx,1004h
int 10h
mov ah,1
int 16h
je continue
jmp start
ret
time endp
compute proc near
push ax
push bx
push cx
push dx
xor cx,cx
mov bx,10
decloop:
sub dx,dx
div bx
inc cx
push dx
cmp ax,0
jnz decloop
mov bx,[minsize]
mov dl,[pp]
pp_rr:
cmp cx,bx
jge poploop
mov byte ptr ds:[di],dl
inc di;
dec bx
jmp pp_rr
poploop:
pop dx
add dl,'0'
mov byte ptr ds:[di],dl
inc di
dec cx
jnz poploop
pop dx
pop cx
pop bx
pop ax
ret
compute endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -