saba7o0o
saba7o0o

Reputation: 35

the code gives me the wrong output in bell triangle (assembly language emu8086)

i want to make bell triangle with the assembly language emu8086 like this

i have problem in this line

mov ch,a[DI-(1+d)] 

d=1 ;variable increment I tried to remove (1+d) and put it 2 to be like this

mov ch,a[DI-2]

it gives me the result that i want but i want to use the variable (d) cause it changes every time

thats where the problem is

J2:
cmp DI,bx
JE J1
mov al, a[DI] 
mov ch,a[DI-(1+d)] //in this line//
add al,ch
inc di
mov a[DI],al
print ' '
call print_num 
mov dl,c 
mov b,dx
jmp J2

thats the output

1
1 2
2 2 2
2 2 2 2

but it should be like this

1
1 2
2 3 5 
5 7 10 15 

i think the problem is the brackets

Upvotes: 2

Views: 777

Answers (1)

Sep Roland
Sep Roland

Reputation: 39166

You can only have varying address components in processor registers.

mov ch,a[DI-(1+d)]

Assuming d is a word sized variable I suggest you code :

push bx  ;Save because you use it elsewhere!
mov bx,d
neg bx
mov ch,a[DI-1+BX]
pop bx

Upvotes: 1

Related Questions