用汇编程序打印一个倒三角星号 如图 * ** *** ** * 30
2012-03-30
stack segment stack
dw 100h dup(?)
stack ends
code segment
assume cs:code
main: mov di,3
mov si,1 ;upper part
upper: mov cx,di
sub cx,si
call spaces
mov cx,si
call stars
call ?crlf
inc si
cmp si,di
jle upper
dec di ;lower part
mov cx,di
lower: call stars
call ?crlf
dec di
mov cx,di
or cx,cx
jnz lower
mov ah,4ch
int 21h
stars proc
jcxz @f
mov dl,'*'
call putc
loop stars
@@: ret
stars endp
spaces proc
jcxz @f
mov dl,' '
call putc
loop spaces
@@: ret
spaces endp
?crlf proc
push dx
mov dl,13
call putc
mov dl,10
call putc
pop dx
ret
?crlf endp
putc proc
push ax
mov ah,2
int 21h
pop ax
ret
putc endp
code ends
end main