Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2D array with nested loops 1

Status
Not open for further replies.

congo123869

Programmer
Oct 6, 2002
2
US
Im kinda new at this assembly thing. My teacher dosn't know much either so he's no help.

Our first program is this...

Compute the transpose of a two dimensional matrix, subject to the folowing requirements...
1. Each element of the matrix will be between 0 and 25,000
2. You should use the DUP directive to declair the matrix.
3. Use the Readint and Writeint from the irvine.lib?????
4. You need to use nested loops for reading and writing the matrices.
5. The original matrix is 5x5
7. The output should have one row of the transpose per line.

I am lost...
can anyone please help with this???

Thanks Congo
 
Hrm, if I remember right a transpose is like this?
1 2
3 4

transpose:
1 3
2 4

??

If so... well first you need to know whether irvine.lib's Writeint changes any registers. Also, if Writeint has any way of formatting the output, and if it can do WORD values, and of course, WHAT DOES IT NEED AS INPUT? Then you need to know how indices work in assembly. And you need to know that since an element can be 25,000 in value, you need to use WORDS (two bytes) - which makes using indices in assembly even harder. You also need to know that this sort of project DOES NOT require you to actually move the data - all you need to transpose is to modify the DISPLAY of the data a goodly bit. I suggest you first use your own data for testing in the source, then add the 'input data' loop later on.

In fact if Writeint is the same as the Writeint procedures I've seen, all you need to transpose the data is:

;Go by column and display as a row
mov si,0
loop1:
mov ax,matrix[si]
Call Writeint
;write this SpaceOutputRoutine routine, or use something from irvine.lib,
;just make sure there's a space after the int.
Call SpaceOutputRoutine
;we take the number on the SAME column, but on the next row.
;each row has 5 elements, each element is 2 bytes, 5*2=??
mov ax,matrix[si+10]
Call Writeint
Call SpaceOutputRoutine
;we take the number still on the SAME column, but on the
;row after the previous one, so add 10 again to the previous
;row. +10, +10, = +20
mov ax,matrix[si+20] ;ditto
Call Writeint
Call SpaceOutputRoutine
mov ax,matrix[si+30] ;ditto, ditto
Call Writeint
Call SpaceOutputRoutine
mov ax,matrix[si+40] ;ditto, ditto, ditto
Call Writeint
;the above, of course, can be looped to make a nested loop,
;so that's YOUR project, man! Prolly, you should use di
;for the inner loop

;write this routine too
Call CrLfOutputRoutine
;next element/column is two bytes too.
add si,2
;each row is 5 elements, 2 bytes/element, so if we reached
;10th byte, next element
cmp si,10
jb loop1

"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top