Search code examples
mipspseudocodemachine-code

translate mips pseudo instruction into machine code


I know how to translate regular MIPS code into machine language, but how to transfer pseudo instructions into machine code? For example pseudo branch instruction ble(branch on less equal). I can not find the opcode for ble on the mips reference sheet. How can I translate it? I tried to resolve ble into two regular instructions, ble $t0, $t1, L >> sub $t0, $t0, $t1 blez $t0, L And then translate the two instructions into machine code. Is it seems to be right? Please help...


Solution

  • I spent a few minutes Googling trying to find some document that listed all the pseudo-instructions in MIPS assembly and their translations, but was unable to come up with success.

    Instead, this link seems to have enough information to get the idea across.

    To address your specific example of the ble $rt, $rs, LABEL pseudo-instruction, I believe that the correct translation into proper instructions is:

    slt $at, $rs, $rt
    beq $at, $zero, LABEL
    

    Where of course $at is the register reserved for the assembler - for instances like this.