The MASM Forum

Miscellaneous => 16 bit DOS Programming => Topic started by: sylent1305 on December 13, 2023, 06:41:16 AM

Title: help me
Post by: sylent1305 on December 13, 2023, 06:41:16 AM
i need help
i need to do the pascal triangle please helpo me
array dw 1, 99 dup(0)
row dw 0
col dw 0
size dw 10
jmp start

start:
    mov [array], 1
    inc row
    mov cx, row
    jmp rowloop

rowloop:
    mov ax,row
    mul size
    mov bx,array
    add bx,ax
    add bx,col
    mov cx,bx
    sub cx,10d
   
loop rowloop 
   
end:
mov ah, 0
int 16h
ret
Title: Re: help me
Post by: NoCforMe on December 13, 2023, 07:26:28 AM
I'm not familiar with that problem (the Pascal triangle), but I can offer a few things:

First of all, this is 16-bit DOS code ("int 16h"), so it really belongs in the 16-bit forum here. You might get better answers there.

Why are you jumping to a label just below the jmp?

"size" is a reserved word in MASM. What size exactly do you want here? You need to state it:
mul size array
or whatever you want the size of (which is the total size in bytes). And oh wait, you can't multiply by an immediate value, which is what you're trying to do: you need to get the value into a register or memory variable:
mov edx, size array
mul edx

You already set the 1st element of "array" to 1, so there's no need for mov [array], 1. (Which is the same thing as mov array, 1, btw.)
Title: Re: help me
Post by: jj2007 on December 13, 2023, 08:06:30 AM
So this is the desired outcome?

I suggest you first formulate your algorithm - use pseudocode, or plain English. Then we can translate that to Assembly, ok?

Note there is a "no homework" rule for this forum, but we can assist you in doing your job. When is your deadline? Did your prof ask explicitly for 16-bit code, or can you do it in 32-bit, too?

(https://www.mathsisfun.com/numbers/images/pascals-triangle-doubles.svg)