在屏幕上显现动态菱形图案(将此文件最大化显示看效果)。
* * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * *
<图一> <图二> <图三> <图四> <图五>
assume cs:code
data segment
dw 0,0,0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov dh,10
mov dl,37
mov cx,5
mov ax,cx
call clear
call sleep
s:
mov ax,cx
cmp ax,5
je next
cmp ax,4
je f1
cmp ax,3
je f2
cmp ax,2
je f3
f3:
mov al,ds:[0]
inc al
mov ds:[0],al
f2:
mov al,ds:[1]
inc al
mov ds:[1],al
f1:
mov al,ds:[2]
inc al
mov ds:[2],al
next:
call rhombus
call sleep
call clear
loop s
mov cx,4
s1:
cmp ax,4
je f6
cmp ax,3
je f5
cmp ax,2
je f4
f4:
mov al,ds:[0]
dec al
mov ds:[0],al
f5:
mov al,ds:[1]
dec al
mov ds:[1],al
f6:
mov al,ds:[2]
dec al
mov ds:[2],al
call rhombus
call sleep
call clear
loop s1
mov ax,4c00h
int 21h
;dh 行 dl 列 cx菱形循环的次数 ax 偏移
rhombus:
push dx
push ax
call show
mov al,ds:[0]
inc dh
sub dl,al
call show
add dl,al
add dl,al
call show
sub dl,al
mov al,ds:[1]
inc dh
sub dl,al
call show
add dl,al
add dl,al
call show
sub dl,al
mov al,ds:[2]
inc dh
sub dl,al
call show
add dl,al
add dl,al
call show
sub dl,al
mov al,ds:[1]
inc dh
sub dl,al
call show
add dl,al
add dl,al
call show
sub dl,al
mov al,ds:[0]
inc dh
sub dl,al
call show
add dl,al
add dl,al
call show
sub dl,al
inc dh
call show
pop ax
pop dx
ret
;dh 行 dl 列
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 byte ptr es:[bx],'*'
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
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
code ends
end start