School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,109 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,001 people online right now. Registration is fast and FREE... Join Now!




MIPS ASSEMBLY QUESTION

 

MIPS ASSEMBLY QUESTION

oldmanklc

8 Jul, 2009 - 07:49 PM
Post #1

New D.I.C Head
*

Joined: 13 Jun, 2009
Posts: 11


My Contributions
Hi,

I have the following pseudo instruction that I need to translate for an assignment:

'add ($Rd)++, ($Rs)++, ($Rt)++'

The ($R) means the value at the address pointed to by the register. The challenge with this is... I can only use $at as a temporary register. Is there a way to add to values in memory without actually moving those values into a register?

What approach should I be taking?

Thanks.

User is offlineProfile CardPM
+Quote Post


no2pencil

RE: MIPS ASSEMBLY QUESTION

8 Jul, 2009 - 07:52 PM
Post #2

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,492



Thanked: 303 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
** Moved to Assembly **
User is online!Profile CardPM
+Quote Post

Neumann

RE: MIPS ASSEMBLY QUESTION

8 Jul, 2009 - 08:11 PM
Post #3

I can judge a book by its cover
Group Icon

Joined: 8 Jul, 2009
Posts: 686



Thanked: 93 times
Dream Kudos: 225
My Contributions
I had a fairly decent experience with MIPS architecture. As far as I can recall, you cannot manipulate data directly inside a memory. And I wouldn't be surprised if that was the case, after all MIPS targets simplicity.

I am pretty sure that you have misread the question. There is no way to perform such an addition with only a single register at hand. You need at least 2 registers. But it would be best to have 3 registers at hand in order to perform your operation in the most efficient way.
User is offlineProfile CardPM
+Quote Post

wildgoose

RE: MIPS ASSEMBLY QUESTION

8 Jul, 2009 - 11:09 PM
Post #4

D.I.C Regular
Group Icon

Joined: 29 Jun, 2009
Posts: 429



Thanked: 56 times
Dream Kudos: 25
Expert In: Assembly,C,C++

My Contributions
Only the 80x86 family allows a mathematical response to memory. Other processors are register to register.

MIPS
Move memory to register
process register with register's
Move result from register to memory

80x86
Does the same but also

process memory with register or immediate

You can't memory = memory + memory
But you can memory += register
register += memory
register += register
register += immediate


Now there may be a trick that I don't remember that allows a particular operation to performed on memory but I don't remember one!


So in your case...
'add ($Rd)++, ($Rs)++, ($Rt)++'

You didn't mention if they were integer or Single-Precision Floating-Point, nor how many bits insize.
There's even other ways to do it using SIMD.


CODE

   lw  $t0, valS
   lw  $t1, valT
   add   $t0, $t0, $t1
   sw   $t0, valD


This post has been edited by wildgoose: 8 Jul, 2009 - 11:12 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 12:54PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month