0

I'm really new in MIPS assembly and I am wondering can I do something like:

enter image description here Not just three characters number, any length of X and Y

Please help If you know the algorithm or where can I find the code or algorithm

(Sorry I thought image might describe better and faster)

Thank you ...

4
  • Yes, you can do that. You're going to have to jump through some hoops. Did you try anything? Commented Jul 10, 2013 at 5:03
  • Yes. actually I'm trying since Friday but still nothing, That's why I asked my question here. Commented Jul 10, 2013 at 5:04
  • @Hooman: What Carl Norum asked, is to post some come you tried that an be commented to help you to make it work. SO is dedicated to coding problems, if you have some code even broken, post it. SO is not a place to ask others to write your code. Commented Jul 10, 2013 at 7:59
  • Does your target MIPS have an FPU? Commented Jul 10, 2013 at 8:23

1 Answer 1

1

Consider the following pseudo-code:

int x = input
int y = input

while y > 1:
    y = y / 10

return x + y

Of course you will have to be cognizant of the normal floating point precision sticking points, i.e. that this can only at best get you as close as possible to XXX.YYY given the representation.

Sign up to request clarification or add additional context in comments.

3 Comments

Perhaps OP should clarify on how the length of Y is specified, but this does not work if I want, for example, X=34 and Y=2 to result in 34.02.
@DrewMcGowen That's a good point. I didn't consider the case of leading zeros in Y because Y is an integer. If that is required then a slightly different approach must be taken.
If you have the digit length, you can just replace the while loop with a for loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.