473,586 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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! =-----
Jul 22 '05 #1
2 2447
Milk <mi*********@ho tmail.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)cybers pace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #2
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.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2622
by: Milk | last post by:
Hi all, Can anyone help me to do this Question. Coz this is my first time study C++ language and my lecture want me to do this kind of program, i really don't have any ideal pls help me here is the Question:: Improve the following (badly written) matrix multiplicationprogram and translate it into MIPs assembly language then assemble into...
1
1499
by: Milk | last post by:
Hi all, Can anyone help me to do this Question. Coz this is my first time study C++ language and my lecture want me to do this kind of program, i really don't have any ideal, or can send me some link is similar this program to me have a look, i already finish the MIPS part and the C Program that part also , but the simulator part is really...
1
289
by: Milk | last post by:
Hi all, did anyone know any good newsgroup about MIPS for me to asking Question?? Thnaks a lot ~ Let us linux ~ -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
9
2755
by: Tim Rentsch | last post by:
I have a question about what ANSI C allows/requires in a particular context related to 'volatile'. Consider the following: volatile int x; int x_remainder_arg( int y ){ return x % y; }
126
4269
by: ramyach | last post by:
Hi friends, I need to write a parallel code in 'C' on the server that is running SGI Irix 6.5. This server supports MIPS Pro C compiler. I don't have any idea of parallel C languages. I looked into few posts in this group. I could make out that there are several languages for parallel programming and parallel C is one of them. I need to know...
4
5891
by: nickpreiser | last post by:
Hi Everyone, I trying to get a build of Python together to run on an Embedded Linux / Mips machine. I run the ./configure --host= XXXmips(my mips proc) --build=XXX x86(my pc). and the configure runs perfectly. I then run "make" and it fails . I have also tried appling some patches, and running autoconf , but I end up with the same...
4
4038
by: angel120 | last post by:
I'm taking a MIPS class, and our first project is to prompt the user to input 8 numbers (using a for loop & an array), and output the minimum and maximum numbers of the array. I wrote the program in C++ (works perfectly), and I've been trying to translate it, but the online tutorials aren't very good. So here's one thing I find difficult to...
6
6295
by: waxinwaxout | last post by:
I'm compiling the same set of c++ sources to both x86 (32 & 64) and to mips32. For x86 I'm using gcc 4.1.2 and for mips I'm using gcc 3.4.6. What I don't understand is why the mips binaries are consistently (and significantly) larger than the x86 binaries. Compiling to x86 without any selected optimization level results in a binary of...
1
2696
by: jty0734 | last post by:
if you have mips cross compiler, please convert this c code to mips code. i'm try to install mips compiler 3 days, but some error fail to that. so if you have something cross compiler c code -mips code , please convert this to me. thx!
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.