how program to display this triangle??? >_<

> *****
> ****
> ***
> **
> *
>      *
>     **
>    ***
>   ****
>  *****

(just the triangle..)

We don't do your homework for you. Show some effort of your own toward solving the problem before simply demanding code.

69951fba4a7e01aa3b2f63af5cc70530

.model small
.code
org 100h

start:
     mov cx, 5

L1:
    push cx

L2:
    mov ah,2h
    mov dl,2Ah
    int 21h
    loop L2
    mov dl,0Ah
    int 21h
    mov dl,0Dh
    int 21h
    pop cx
    loop L1
    mov cx,5

L3:
    push cx

L4:
    mov ah,2h
    mov dl,20h
    int 21h 
    loop L4


    mov dl,2Ah
    int 21h

    mov dl,0Ah
    int 21h
    mov dl,0Dh
    int 21h
    pop cx

    loop L3

exit: int 20h
end start

I just can do this... (> <) to display
to display the triangle below, I still can not....

There's a flaw in your second loop. You're printing the right amount of spaces, but you're only printing one *, hence you don't end up with this:

>      *
>     **
>    ***
>   ****
>  *****

To achieve the above, you need to introduce a counter much like you did in your first loop so that after you've printed the spaces, you print 1 * for the first line of the above pattern, 2 for the next and so on.

It's a bit difficult for me to put into words clearly, but I hope it's helped somewhat.

Hi,
Can you give a test to this code:

.286
.model small

.stack 1024h
.code

start:
    mov cx, 5
first:
    mov bl, 2ah
    mov bh, 1
    call    drawall
    loop    first

    mov dx, 5
second:
    mov bl, 20h
    mov bh, 0
    mov cx, dx
    call    drawall
    mov cx, 6
    sub cx, dx
    mov bl, 2ah
    mov bh, 1
    call    drawall
    dec dx
    jnz second
    mov ax, 4c00h
    int 21h


drawall:
    push    ax
    push    bx
    push    cx
    push    dx
drawone:
    mov     ah,2h
    mov     dl,bl
    int     21h
    loop    drawone
    or  bh, bh
    jz  retorn
    mov     dl,0Ah
    int     21h
    mov dl,0Dh
    int 21h
retorn:
    pop dx
    pop cx
    pop bx
    pop ax
    ret

    end start

Please, forgive me if I am wrong.

Cheers.

.MODEL SMALL
.STACK  50H
.DATA
    NL  DB  0DH, 0AH, '$'         ; NL = NEXT LINE
.CODE
MAIN PROC
    MOV AX, @DATA
    MOV DS, AX

    MOV CX, 5
    MOV BX, 1

    FOR_1:
        PUSH    CX
        MOV DL, 20H    ; 20H IS ASCII CODE FOR SPACE
        MOV AH, 2

        FOR_2:
            INT 21H    ; PRINTING SPACES
        LOOP    FOR_2

        MOV CX, BX
        MOV DL, '*'
        MOV AH, 2

        FOR_3:
            INT     21H    ; PRINTING STARS
        LOOP    FOR_3

        LEA DX, NL
        MOV AH, 9
        INT     21H    ; MOVE CURSOR TO THE START OF NEXT LINE
        INC BX
        POP CX

    LOOP    FOR_1

    MOV AH, 4CH
    INT         21H
MAIN ENDP
    END MAIN
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.