1

Here's the C representation of what I'm trying to do in MIPS assembly:

printf ("x=%d\n", x);

I know that I can do a syscall to easily print x= and I can also do a syscall to print the int x (which is stored in a register). However, that prints them like this (let's say x is 5):

x=

5

How can I make them print on the same line?

1
  • I'm running this is the MARS simulator. Commented Apr 22, 2010 at 15:23

3 Answers 3

3

Look at the Fibonacci.asm example: http://courses.missouristate.edu/KenVollmar/MARS/Fibonacci.asm - it seems to be a good example of exactly what you need to do - look at the part near the print: label. It looks like you needs syscall 4 for printing the x = part and syscall 1 for printing the integer itself.

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

Comments

1

Use a syscall for printing the x= which does not add a line feed.

What that syscall might be is system specific, and you are not mentioning anything about the system.

Comments

1

If you print with two separate characters, 'x' and '=', you should avoid the newline problem.

Comments

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.