I tried to make a program that will calculate Pascal's triangle, however my program is incorrect.
org 100h
; Set an array with size equal to 100
array db 1, 99 dup(0)
_start:
mov si, 1 ;repreasent if we add already 100 values and we should stop the loop
mov di, 1 ;di set to be the row
mov bp, 0; bp set to be the index
mov [array + di * 10 ], 1
mov [array + di * 10 + 1], 1
inc si
inc si
inc di ;we start from row number 2
;lets move to a new row
jmp move_to_new_row
;after the move to the enew row is finish we go the full array and we want to print it out
mov ax, 0
jmp move_over_array
;this lable make sure to load values to array
add_values_to_row:
mov al, [array + <(di - 1) * 10> + bp]
mov dl, [array + <(di -1) * 10 > + bp -1]
add al, dl ; add the arr[line - 1][i] + arr[line- 1][i-1]
mov [array + bp], al; set the index to the sum of indedxes in the privios line
inc si ; adding to the numbers of adding values 1
;update the values
inc bp;adding 1 to the index
move_to_new_row:
mov [array + di], 1 ;set the first index of the new row to be 1
mov bp, 1 ; we starting full the row from index = 1
mov cx, 10 ; move the loop 10 times
loop add_values_to_row ;full the new row
;now we full a row good lack lets go to the new row
inc di; adding 1 to the row
cmp si, 100 ;checking if we adding to the array all the 10 lines
JB move_to_new_row ; add another line for full
print_new_line:
mov bl , 0
PRINTN " "
print_using_ax:
mov bx, ax ; Move the value from al to bx
mov al, [array + bx] ; Use bx as an index
call print_num
inc ax ; Increment the index (assuming 16-bit elements, adjust accordingly)
inc bl
cmp bl, 10
JE print_new_line
move_over_array:
mov bl, 0
;move over the array and print the value using ax register
loop print_using_ax
int 16h
ret
; Include magshimim library used for print and so on
include magshimim.inc