I should find max in a multidimensional array. But, the elements of the array are given by keyboard, and so is the size of the array. The elements are integers. So, is this correct:

;message for the user to enter the size
i equ -1
j equ 0
loopForI:
inc i
loopForJ:
;message for the user to enter the element
mov ax,size
mul i
add ax,ax; because integer's size is two
mov bx,ax
mov matrix[bx],element
inc j
cmp j,golemina-1
jne loopForJ
jmp loopForI
inc i

Hi

seems to be a bigger task, not just suitable for first-year students. First, I suppose you want to input two-dimensional matrices (not multi-dim. ones), because of your both loops i,j. If so, you should decide how your 2D matrix is to store. In principle, you can do that column by column or row by row. Here is some algorithm in principle for the latter approach:

``````Let m be the number of columns (length of row), n be the number of rows (length of column) and di the offset for storing element A(i,j) of matrix A, then

set di = 0
for i = 0 to n-1 do
for j = 0 to m-1
get element A(i,j) from input
compute address of Element A(i,j) by ij = di + j;
store element A(i,j) in A(ij)
next j
set di = di + m
next i``````

Btw, address can also be computete by m*(i-1) + j which is somewhat ineffective.

You need to know how to input integer values. That may depend on the assembly tool you are working with, for example winASM has nice procedures StdIn and StdOut for managing I/O. In detail you need to know the allowed adressing modes both your processor and assembler supplies. There are assemblers not offering all possible modes, for example indirect addressing such as AX[BX+offset] sometimes missing.

So if you will have to figure out these things, we could proceed.

-- tesu

Be a part of the DaniWeb community

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