Why do my MIPS crosscompiler works like this for NOT operation?

1.7k views Asked by At

I setup my crosscompiler for making MIPS instructions.

And it compiles C code well.

but I found a weird thing for NOT operations.

if i make code like

   int a;
   func(!a);

and i studied MIPS instructions with text book that says "MIPS converts NOT operation to 'nor with zero'"

So i thought it would converted like

 nor a a $zero

but my compiler converts

xori a a 0x0
sltu a 1

/////////////////////////////////////// i compiled the code with 'myaccount>> mipsel-unknown-linux-gnu-gcc -S myfilename.c' and it makes myfilename.s file..

what am i missing??

1

There are 1 answers

0
Gabe On

You are confusing "not" operations. The "nor with 0" operation is ~a (1's complement), while you wrote !a (which returns 1 if the operand is 0 or 0 otherwise).