键盘接收0 ~ 9之间的数,屏幕输出如下图形(以输入6为例),按‘Q’键退出系统运行。
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
在着里先谢谢了
data segment
buf db 2
db ?
db 1 dup(0)
data ends
code segment
main proc far
assume cs:code,ds:data
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
flag1:
mov dx,offset buf
mov ah,10
int 21h
sub buf+2,30h
mov al,buf+2
cmp al,65
jz exit
cmp al,10
jns flag2
cmp al,1
js flag2
mov cl,al
mov ch,0
mov dl,1
again1:
push cx
mov cl,dl
push dx
add dl,30h
again2:
push dx
mov ah,2
int 21h
mov dl,' '
mov ah,2
int 21h
pop dx
loop again2
mov dl,13
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
pop dx
inc dl
pop cx
loop again1
mov al,buf+2
dec al
cmp al,0
jz flag2
mov cl,al
mov ch,0
mov dl,al
again3:
push cx
mov cl,dl
push dx
add dl,30h
again4:
push dx
mov ah,2
int 21h
mov dl,' '
mov ah,2
int 21h
pop dx
loop again4
mov dl,13
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
pop dx
dec dl
pop cx
loop again3
flag2:
jmp flag1
exit:
ret
main endp
code ends
end start
[此贴子已经被作者于2007-7-4 12:46:08编辑过]