I'm trying to convert the following C code to MIPS64 (very new to this):

If Im given the addresses: (a @ 100) (b @ 200) (c @ 300)

long int a, b, c; // 64-bit


if (a < b || a == 4)
    c = 1;
    c = 0;

The last time I did this (was for work) we used a C complier.

I am assuming this a class assignment, or some sort of training exercise, since, as @rproffitt said, for any sort of work project the logical solution would be to compile the C code.

Now, both for ethical reasons and due to DaniWeb TOS, we cannot just give you the code. Even if this weren't the case, we'd need to know which development target and toolchain you are using, and what restrictions on the solution exist if any, as the obvious answer would involve using pseudo-instructions, which not all assemblers support, and not all professors permit. It might be useful if you can tell us if you need to manually hoist load and branch slots, as well (though since you said MIPS64, and I am pretty sure delay slots don't apply to any 64-bit versions of MIPS, it probably doesn't matter).

We can give you advice on how to write it, however. I would recommend starting by looking at the documentation on the instructions lw, beq, j, and sw, as well as the pseudo-instructions blt, and li. Once you have that, if you still have problems, try posting the code here (with the necessary information about the tools you are using) and we'll see what we can tell you.


int main()

int i;
return 0; 

I want this program into mips labguage

int i;



return 0;

@raj_30: Permit me to point you toward the Daniweb Forum Posting Rules before proceeding, as you just broke some of them. As a new member, you will be forgiven - mostly - for these mistakes, but you really don't want to make one of the regulars remind of these again.

  • Do not hijack old forum threads by posting a new question as a reply to an old one
  • Do not post the same question multiple times
  • Do provide evidence of having done some work yourself if posting questions from school or work assignments
  • Do post in full-sentence English
  • Do not write in all uppercase or use "leet", "txt" or "chatroom" speak

This last two are generally considered to also cover the practice of posting a series of fragmentary posts in the manner of a chat room or Twitter feed. As my own post demonstrates, you are not limited to 144 (or even 288) bytes of plain text, and posting sentences separately which could be part of a single post is irritating and inappropriate. Note also that you can edit posts up to 30 minutes after they have been submitted, so typos can be corrected after the fact as well (up to a point; we will forgive it if you simply didn't notice it until after that 30 minute window).

This forum is also unlike a chat room in that it can take hours or even days before someone gets around to reading and replying to a message, if at all. While faster turn-around can occur, it is uncommon, so patience is necessary in most kinds of message boards.

So, please do not ask a new question in someone else's existing thread; start a new thread, instead. Once you have made your own thread on the topic, including a detailed, single-post explanation of the assignment and what you have already done to try to complete it, then we will give you what answers we can.

I will tell you this much, however: we would need more information to answer this question. Specifically, you need to tell us - in another thread, as I already stated - what MIPS system or MIPS emulator you are using, as the equivalent to printf() will differ for different hardware and operating systems. I am guessing that you are running this in one of the more common emulators such as SPIM or MARS, but that's just a guess and we would need to know for certain before answering.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.