数字金字塔
在屏幕上输出
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
记得当初用c语言做的,现在我改用汇编来做了,能运行出结果,
不过自己感觉有些语句太多余了,挺烦的,希望仁兄们能帮我瘦瘦身,
或指点些简便的算法!!!!!
代码如下:
cseg segment
assume cs:cseg
start: mov bp,'1'
mov cx,8
next: xor bx,bx
mov bx,'0'
push cx
aa: cmp cx,0
jz bb
mov dx,' '
mov ah,2
int 21h
loop aa
bb: inc bx
mov dx,bx
mov ah,2
int 21h
cmp bx,bp
jnz bb
cmp bx,'1'
jnz cc
jmp next1
cc: dec bx
mov dx,bx
mov ah,2
int 21h
cmp bx,'1'
jz next1
jmp cc
next1: pop cx
cmp cx,0
jz next2
call te
inc bp
dec cx
jmp next
te proc
push ax
push dx
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
pop dx
pop ax
ret
te endp
next2: mov ah,4ch
int 21h
cseg ends
end start
[此贴子已经被作者于2007-6-2 0:07:45编辑过]