Question about my MIPS Program



 DEVELOP > c-Plus-Plus > Question about my MIPS Program

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Milk"
Date: 14 Apr 2004 07:47:39 AM
Object: Question about my MIPS Program
Hi,
i got a program working half part and my program is suppose to do 4*4 matrix
can any one help me to check it? i dunno whic part i did wrong thx~~
Here is the program :::::
.data
arrayA: .space 1024
arrayB: .space 1024
arrayC: .space 1024
str: .asciiz " "
.text
main:
move $s1, $zero #initial j to 0
move $s2, $zero #initial i to 0
move $s3, $zero #initial k to 0
li $t4, 4
move $t0, $zero #initial array A to 0
move $t1, $zero #initial array b to 0
move $t2, $zero #initial array c to 0
L1:
mul $s4, $s1, $s2 #s4 = ixj
la $t6, arrayA($t0) #loading the array address
sw $s5, 0($t6) #a[i][j] = ixj
addiu $t0, $t0, 4 #move to next array location in matrix a
la $t7, arrayB($t1) #loading the array address
sw $s4, 0($t7) #b[i][j] = ixj
addiu $t1, $t1, 4 #move to next array location in matrix b
#-----------------------------------------------------------------------
li $v0, 1 #print int
addu $a0, $s4, $zero #print out matrix a[i][j]
syscall
#-------------------------------------------------------------------------
addiu $s2, $s2, 1 #s2 i add 1
bne $s2, $t4, L1 #if s2 not equal 4 go back L1
li $s2, 0 #initial i to 0
addiu $s1, $s1, 1 #s1 j add 1
bne $s1, $t4, L1
#--------------------------------------------------------------
move $s1, $zero #reset j to 0
move $s2, $zero #reset i to 0
move $s6, $zero
move $t0, $zero #reset array A to 0
move $t1, $zero #reset array b to 0
move $t6, $zero #reset t6
move $t7, $zero #reset t7
L2:
la $t8, arrayC($t2) #load an array address
sw $s6, 0($t8) #arrayC = s6
L3:
la $t3, arrayA($t0) #load value from array A to t3
lw $s8, 0($t3)
la $t9, arrayB($t1) #load value from array B to t3
lw $s7, 0($t9) #c[k][i] = 0
mul $t5, $s8, $s7 #a[k][j]b[j][i]
add $s7, $s7, $t5 #c[k][i]=c[k][i]+a[k][j]*b[j][i]
#-----------------------------------------------------------------------
li $v0, 1 #print int
addu $a0, $s7, $zero #print out matrix a[i][j]
syscall
#------
mul $t6, $s3, $t4 #t6= k*16
add $t6, $t6, $s1 #t6= k*16+j
mul $t0, $t6, 4 #move to next address in arrayA
mul $t7, $s1, $t4 #t6= j*16
add $t7, $t7, $s2 #t6= j*16+i
mul $t0, $t7, 4 #move to next address in arrayB
addi $s1, $s1, 1 #j+1
bne $s1, $t4, L3
add $s6, $s0, $zero
move $s1, $zero
addi $t8, $t8, 4 #add address of arrayC
addi $s3, $s3, 1
bne $s3, $t4, L2
move $s3, $zero #reset k to zero
addi $s2, $s2, 1
bne $s2, $t4, L2
exit:
li $v0, 10
syscall
~ Let us linux ~
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
.

User: "Christopher Benson-Manica"

Title: Re: Question about my MIPS Program 14 Apr 2004 07:52:53 AM
Milk <milkmilk776@hotmail.com> spoke thus:

i got a program working half part and my program is suppose to do 4*4 matrix
can any one help me to check it? i dunno whic part i did wrong thx~~

PLEASE read the welcome message - this is not comp.lang.MIPS.assembly!
http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
.

User: "Kevin Goodsell"

Title: Re: Question about my MIPS Program 14 Apr 2004 02:54:21 PM
Milk wrote:
[One of the least topical posts ever seen on this group.]
Yeah, I think we've had about enough of you.
Shall we, gentlemen?
*PLONK*
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER