![]() |
|
#1
|
|||
|
|||
MIPS 64-bit subtractionHello all, I'm quite new to programming, and I'm trying to impliment 64-bit subtraction in MIPS.
This is how I have things set up. X and Y are 64-bit positive integers, where each is represented as an array of two 32-bit positive integers. That is, X[0] and Y[0] contain the high order 16 bits, and X[1] and Y[1] contain the low order 16 bits. I'm a little bit stuck here, as I don't know how to proceed. If anyone could point me in the right direction I would be greatly appreciative. Thanks! |
|||
|
#2
|
|||
|
|||
Re: MIPS 64-bit subtractionCould you post:
- a minimal sample of the code you are trying to do that runs. - a sample of what you are trying to include in the above which you are having trouble with. - A statement that expresses why YOU think it doesn't work. - Also - what compiler are you using? |
|
#3
|
|||
|
|||
Re: MIPS 64-bit subtractionI'm sorry, perhaps I should have been more clear. I'm a little stuck on the concept. I think I could figure out the code if I knew where to begin. I'm more stuck on, "what do I need to subtract from where to obtain the correct value". Like, do I need to subtract Y[0] from X[0]? Or something else?
I'm using MARS for the compiler. courses.missouristate.edu *EDIT* For some reason the link won't post. Code:
Thanks for the response. |
|
#4
|
|||
|
|||
Re: MIPS 64-bit subtractionI downloaded and tried it out. Nice IDE.
As far as working with 64 bit values goes, Use the 64 bit registers on one of the new 64 bit cpus! haha Seriously, I'm not sure what to tell you as I have never done this. I have been trying to find a good reference but it is late. I have seen it described for working with 32 bit values in 16 bit registers. Above you are using 16 bit array elements,,, so are you working with a cpu with 16 bit registers? or 32? sorry I can't be of more help I can look some more tomorrow. Maybe someone else could help us both. |
|
#5
|
|||
|
|||
Re: MIPS 64-bit subtractionI believe I mis-spoke, X[0] and Y[0] should contain the high order 32 bits, and X[1] and Y[1] contain the low order 32 bits.
|
|
#6
|
|||
|
|||
Re: MIPS 64-bit subtractionQuote:
I am assuming you are using a 32-bit machine with 32-bit add/subtract instructions. Here are some considerations for multiple-precision integer subtraction: First of all, for simplicity, assume that the integers are unsigned, and there are instructions to perform binary subtraction. If there were a separate unsigned "subtract with borrow" instruction, as there is in just about all CISC machines, and if there were a "borrow" status bit that is set according to the results of any subtraction operation, this is how you would do it. (That is, this is how I would do it): Code:
See the following for a discussion of why there is not an "add with carry" operation on standard MIPS machines. (The reasoning, obviously, applies to the question of why there is no "subtract with borrow" instruction on MIPS machines.) There is an example of multi-precision addition. http://yarchive.net/comp/carry_bit.html Now, see the following for examples of multiple-precision addition and other operations on standard MIPS machines: http://staff.science.nus.edu.sg/~phy...tut5answr.html Extrapolating from the addition example, consider the following for multiple-precision subtraction: Code:
Regards, Dave Last edited by davekw7x : 08-Apr-2009 at 11:49.
|
|
#7
|
|||
|
|||
Re: MIPS 64-bit subtractionQuote:
Actually it looks as if the sgtu instruction might be more appropriate for this logic condition. Regards, Dave |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mips Array/Loop assistance | SpeedisaVirus | Assembly Language | 2 | 19-Sep-2008 14:17 |
| Request code for a non-recursive binary search in MIPS | ks_100 | Assembly Language | 0 | 15-Feb-2008 12:10 |
| MIPS instructions | kokopo2 | C Programming Language | 7 | 24-Aug-2005 13:50 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The