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;

Edited by Andrew_46

3 Weeks
Discussion Span
Last Post by Schol-R-LEA

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.

Edited by Schol-R-LEA: typo

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.