我需要创建一个打印四个三角形的程序。前两个面向右侧,其他两个面向左侧。我不知道如何使他们朝左。
我尝试重用前两个三角形的代码并对其进行修改以适应作业的需要,但是打印不正确
org 100h
.model small
.stack 256
.data
input db "Enter the size for the triangles between 3 and 9, or 0 to quit: $"
size dw ?
.code
main proc
mov AX, @data
mov DS, AX
prompt:
mov AH, 09h
lea DX, input
int 21h
mov AH, 01h
int 21h
cmp AL, '0'
;je exit
sub AL, '0'
mov AH, 0
mov size, AX
mov CX, AX
mov BX, 1
call CRLF
;---------------------------------------------------
; First Triangle
lines1:
push CX
mov CX, BX
stars1:
mov AH, 02h
mov DL, '*'
int 21h
loop stars1
call CRLF
inc BX
pop CX
loop lines1
space3:
mov AH, 02h
mov DL, '-'
int 21h
call CRLF
mov CX, size
;---------------------------------------------------
; Second Triangle
lines2:
push CX
space2:
mov AH, 02h
mov DL, ' '
int 21h
stars2:
mov AH, 02h
mov DL, '*'
int 21h
loop stars2
call CRLF
pop CX
loop lines2
call CRLF
mov CX, size
mov BX, 1
;--------------------------------------------------
;triangle 3
lines3:
push CX
;mov CX, BX
stars3:
mov DL, '*'
mov AH, 02h
int 21h
loop stars3
call CRLF
inc BX
pop CX
loop lines3
call CRLF
mov CX, size
mov BX, 1
;---------------------------------------------------
; space
lines4:
push CX
mov CX, BX
space1:
mov AH, 02h
mov DL, '-'
int 21h
loop space1
call CRLF
inc BX
pop CX
;---------------------------------------------------
; foruth Triangle
lines5:
push CX
space:
mov AH, 02h
mov DL, ' '
int 21h
stars4:
mov AH, 02h
mov DL, '*'
int 21h
loop stars4
call CRLF
pop CX
loop lines5
call CRLF
mov CX, size
mov BX, 1
;--------------------------------------------------
main endp
CRLF proc
mov AH, 02h
mov DL, 13
int 21h
mov DL, 10
int 21h
ret
CRLF endp
输出应该如下。我有能够打印的前两个三角形,但是没有第二个三角形。