# Assembly Programming Help

This topic is 4233 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I need to write a programming using the MIPS ISA to compute the saddle point of a 4x4 matrix. The saddle point is a value that is the maximum value in a row and the minimum value in its column. There can be more than one saddle point in a matrix and all the saddle points need to be printed to the console. Also, if there is no saddle point then an appropriate message needs to be printed to the console. I do not how to get started with this program. Any help would be appreciated. Thanks.

##### Share on other sites
The forum has a strict policy on doing people's homework for them, so I can only give you advice:

Think hard about how you could store a 4x4 matrix in memory. Once you've decided and written out all the details, it shouldn't be too difficult to write functions to perform basic matrix arithmetic.

For this task you'll need to understand the mathematics behind, and be able to implement the code for;

1. Matrix scaling. Write a function that multiplies every element by a given constant. If you don't know how to start with this, then you're out of your depth with regards to the language.

3. Matrix trace and determinant.

4. Determination of eigenvalues. There are several ways to do this. The trade is between programming time and execution time.

This constitutes the guts of the problem. If you get this far then adding the glue and garnish should be relatively simple.

It would be a good idea to plan the whole project out before you start coding though. A common strategy, when overwhelmed like this, is to draw a flow-chart; recursively breaking the problem down into its constituent parts. Once you have visualised how the problem consists of smaller ones you know how to solve, it all comes a lot easier.

Good luck

##### Share on other sites
I have written a solution to this program in C and am trying to convert the C code to MIPS assembly. Both my C and my assembly codes are below. I am using PCSpim to run the assembly and am getting a lot of errors. If anyone can see what I am doing wrong or help me out in anyway I would really appreciate it. I am new to assembly and can really use the help. Thanks.

#include<stdio.h> int main(){   int a[3][3],i,j,k,min,max,col,count=0;   printf("enter elements row-wise");    for(i=0;i<4;i++)    {     for(j=0;j<4;j++)      {       scanf("%d",&a[j]);      }   }    for(i=0;i<4;i++)    {     min=a[0];     for(j=0;j<4;j++)      {       if(a[j]<=min)        {         min=a[j];         col=j;         }      }     max=a[0][col];     for(k=0;k<4;k++)      {       if(a[k][col]>=max)        {         max=a[k][col];         }      }    if(max==min)     {      printf("saddle pt.at (%d,%d)",i+1,col+1);      count++;     }   }  if(count==0)  printf("no saddle points");  }

.datastrA:		.asciiz "Saddle Point Value:"strB:		.asciiz "There are no saddle points"newline:	.asciiz "\n"space:		.asciiz "  ".align 2A0:	.word 1, 2, 3, 4A1:	.word 5, 6, 7, 8A2:	.word 5, 6, 7, 8A3:	.word 1, 2, 3, 4.textmain: 	li $t0, 4 la$t1, A0	li $t3, 4 li$t8, 4	li $s4, 0loop1: lw$t2, 0($t1) move$t4, $t1loop2: lw$t5, 0($t4) bgt$t5, $t2, Next move$t2, $t5 move$t6, $t4Next: addi$t4, $t4, 4 addi$t3, $t3, -1 bne$t3, $zero, loop2 lw$t7, 0($t6) move$t9, $t7loop3: lw$s0, 0($t9) blt$s0, $t7, Skip move$s1, $s0Skip: addi$t9, $t9, 16 addi$t8, $t8, -1 bne$t8, $zero, loop3 bne$s1, $t2, No la$a0, strA	li $v0, 4 syscall move$a0, $s1 li$v0, 1	syscall	la  $a0, newline li$v0, 4           	syscall 	addi $s4,$s4, 1No:	addi $t1,$t1, 16	addi $t0,$t0, -1	bne  $t0,$zero, loop1	beq  $s4,$zero, Nos	j eNos:	la $a0, strB li$v0, 4	syscalle:	li \$v0, 10	syscall

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633744
• Total Posts
3013653
×