assume cs:code
code segment
start:
mov dh,10
mov dl,30
mov cl,2
mov ch,3
mov al,0
call clear
call sleep
s:
call rhombus
call sleep
call clear
add al,2
cmp al,6
je s1
jmp s
s1:
call rhombus
call sleep
call clear
sub al,2
cmp al,-2
je finish
jmp s1
finish:
mov ax,4c00h
int 21h
clear:
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov cx,2000
mov bx,0
s2:
mov byte ptr es:[bx],' '
add bx,2
loop s2
pop es
pop cx
pop bx
ret
;dh 行 dl 列 ch 字符 cl 颜色 ah 距原点距离 中心的菱形
rhombus:
push ax
push cx
push dx
sub dh,al
call show
sub dl,al
call show
add dh,al
call show
add dh,al
call show
add dl,al
call show
add dl,al
call show
sub dh,al
call show
sub dh,al
call show
pop dx
pop cx
pop ax
ret
;dh 行 dl 列 ch 字符 cl 颜色
show:
push dx
push bx
push ax
mov ax,0b800h
mov es,ax
mov ax,160
mul dh
mov bx,ax
mov ax,2
mul dl
add bx,ax
mov es:[bx],cl
mov es:[bx+1],ch
pop ax
pop bx
pop dx
ret
sleep:
push ax
mov al,0
out 70h,al
in al,71h
mov ah,al
slp0:
mov al,0
out 70h,al
in al,71h
;sub al,ah
cmp al,ah
jne over
jmp slp0
over:
pop ax
ret
code ends
end start
sleep函数说明:
*获取系统时钟,当秒数改变时跳出
*jne over 若将其换为je,上面换为
sub al,ah
cmp al,1
当系统时间为59s时会发生错误
且当系统时间为9s,10s也会发生错误,因为系统时间是以bcd码存放