21,500
社区成员
发帖
与我相关
我的任务
分享
data segment
buffer db 11
db ?
db 10 dup(0)
data ends
codesg segment
assume cs:codesg, ds:data
outclk: mov ax, data
mov ds, ax
;;;;;;;;;;;;;;;;;;显示输出 ‘:';;;;;;;;;
mov dl, ':'
mov ah, 2
int 21h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;以dx为入口,输入时间;;;;;;;;;;;;;;;;;;;;就是在这里,为什么生成的程序没有要求输入,就直接执行后面的代码,开始输出了
lea dx, buffer
mov ah, 0ah
int 21
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;将字节的4高位清空;;;;;;;;
mov bx, offset buffer+2
mov al, [bx]
and al, 0fh
mov [bx], al
inc bx
mov al, [bx]
and al, 0fh
mov [bx], al
inc bx
inc bx
mov al, [bx]
and al, 0fh
mov [bx], al
inc bx
mov al, [bx]
and al, 0fh
mov [bx], al
inc bx
inc bx
mov al, [bx]
and al, 0fh
mov [bx], al
inc bx
mov al, [bx]
and al, 0fh
mov [bx], al
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;将反码转换为BCD码;;;;;;;;;
;;;;;;;并将时,分,秒分别储存在;;;;;;
;;;;;;;;;;;;;;;;;ch,dh,dl;;;;;;;;;;;;;;
mov bx, offset buffer+2
call toBcd
mov ch, al
add bx, 3
call toBcd
mov dh, al
add bx, 3
call toBcd
mov dl, al
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
again:
;;;;;;;;;;;;dis过程为延迟;;;;;;;;;;;;;
call dis
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov al, dl
add al, 1
daa
mov dl, al
cmp al, 60h
jne dispy
mov dl, 0
mov al, dh
add al, 1
daa
mov dh, al
cmp al, 60h
jne dispy
mov dh, 0
mov al, ch
add al, 1
daa
mov ch, al
cmp al, 24h
jne dispy
mov ch, 0
dispy:
;;;;;;重新设置入口参数;;;;;;;;
mov bx, offset buffer
mov al, 0dh
mov [bx], al
inc bx
mov al, 0ah
mov [bx], al
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
inc bx
mov al, ch
call tran
inc bx
mov al, ':'
mov [bx], al
inc bx
mov al, dh
call tran
inc bx
mov al, ':'
mov [bx], al
inc bx
mov al, dl
inc bx
mov al, dl
call tran
inc bx
mov al, '$'
mov [bx], al
;;;;;;;;;;;调用中断,进行输出;;;;;;;;
push bx
push cx
push dx
mov dx, offset buffer
mov ah, 9
int 21h
mov ah, 06
mov dl, 0ffh
int 21h
pop dx
pop cx
pop bx
jnz go
jmp again
go: mov ah, 4ch
int 21h
toBcd:
mov al, [bx]
shl al, 1
shl al, 1
shl al, 1
shl al, 1
or al, [bx+1]
ret
tran:
mov cl, al
shr al, 1
shr al, 1
shr al, 1
shr al, 1
or al, 30h
mov [bx], al
inc bx
mov al, cl
and al, 0fh
or al, 30h
mov [bx], al
ret
dis:
push cx
push ax
mov cx, 0ffffh
goon: dec cx
jne goon
pop ax
pop cx
ret
codesg ends
end outclk