assume cs:code
code segment
start:
call empty
clock:
mov ax,0
mov es,ax
push es:[9*4]
pop ds:[0]
push es:[9*4+2]
pop ds:[2]
mov word ptr es:[9*4],offset int9
mov es:[9*4+2],cs
mov ax,0b800h
mov es,ax
begincoloc:
mov al,'2'
mov es:[0],al
mov al,'0'
mov es:[2],al
mov bx,4
mov cx,3
mov dl,9
c0:
push cx
mov al,dl
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[bx],ah
add bx,2
mov byte ptr es:[bx],al
call slash
pop cx
dec dl
loop c0
mov cx,3
mov dl,4
c1:
push cx
mov al,dl
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[bx],ah
add bx,2
mov byte ptr es:[bx],al
call colon
pop cx
sub dl,2
loop c1
call delay
jmp begincoloc
mov ax,0
mov es,ax
push ds:[0]
pop es:[9*4]
push ds:[2]
pop es:[9*4+2]
mov ax,4c00h
int 21h
;*************函数*************;
empty:
mov ax,0b800h
mov es,ax
mov cx,2000
mov di,0
mov al,' '
e:
mov es:[di],al
add di,2
loop e
mov bx,0
mov cx,0
mov di,0
mov si,0
ret
slash:
cmp dl,7
je blank
add bx,2
mov al,'/'
mov es:[bx],al
add bx,2
jmp short sret
blank:
add bx,2
mov al,' '
mov es:[bx],al
add bx,2
jmp short sret
sret:
ret
colon:
cmp dl,0
je blanks
add bx,2
mov al,':'
mov es:[bx],al
add bx,2
jmp short srets
blanks:
add bx,2
mov al,' '
mov es:[bx],al
add bx,2
jmp short srets
srets:
ret
delay:
mov dx,5h
mov ax,0
d:
sub ax,1
sbb dx,0
cmp ax,0
jne d
cmp dx,0
jne d
ret
;*************中断例程************;
int9:
push ax
push bx
push es
in al,60h
pushf
call dword ptr ds:[200h]
cmp al,1
jne int9ret
mov ax,0b800h
mov es,ax
mov cx,12
mov di,1
i:
inc byte ptr es:[di]
inc di
loop i
int9ret:
pop es
pop bx
pop ax
iret
int9end:
nop
code ends
end start
这是 王爽的汇编语言一书 我想要实现 在不断更新的系统时间 时按下esc键 实现变色效果 但一按esc键 整个程序就卡住了
------解决方案--------------------
int9 上的问题吧,你保存原向量时 pop ds:[0] 之类的,ds 设置了吗,ds:[0] 在哪里?而在 int9: 里又是 call dword ptr ds:[200h] 这又是在哪里,前后还不一致,也都没见过设置 ds 的?
另外,改变颜色的话,每次应该给 di 增 2 因为一个字节是显示字符,再一个字节是显示的属性;再,你的需要修改的也不止 12 个字符吧。