News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

help me

Started by sylent1305, December 13, 2023, 06:41:16 AM

Previous topic - Next topic

sylent1305

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

NoCforMe

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.)
Assembly language programming should be fun. That's why I do it.

jj2007

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?