codesg segment
assume cs:codesg
start:
mov bl,0
rotate:
mov dl,13
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
inc bl
cmp bl,7
jg exit
cmp bl,4
jg either
mov bh,bl ;we can't change the value of bl by 'mul' or 'add'
add bh,bh ;ch=2bl-1
dec bh
mov ch,bh
mov bh,bl ;cl=4-bl
mov al,4
sub al,bl
mov cl,al
jmp print1 ;print space whose ASCII is 20h
either:
mov bh,bl ;ch=15-2bl
mov al,15
add bh,bh
sub al,bh
mov ch,al
mov bh,bl
sub bh,4
mov cl,bh
print1:
cmp cl,0
jle print2 ;print star whose ASCII is 2ah
mov dl,20h
mov ah,2
int 21h
dec cl
jmp print1
print2:
cmp ch,0
jle rotate
mov dl,2ah
mov ah,2
int 21h
dec ch
jmp print2
exit:
mov ah,4ch
int 21h
codesg ends
end start

这篇博客介绍了一段使用汇编语言编写的代码,该代码用于在屏幕上显示一个菱形图案。通过一系列的条件判断和字符输出,实现了从空格到星号的交替打印,从而构成菱形的形状。
最低0.47元/天 解锁文章
2107

被折叠的 条评论
为什么被折叠?



