Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

2D array with nested loops

2D array with nested loops

2D array with nested loops

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

RE: 2D array with nested loops

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

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
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."

RE: 2D array with nested loops

Thanks Man Great help!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close