Hab
Hab

Reputation: 11

Mips Assembly Language Convert C conditional

How to convert following C conditional statement in MIPS? if (A<=B || B == D) where suppose A is stored in $t2, B in $t4, D in $t6

Upvotes: 0

Views: 482

Answers (1)

Tom
Tom

Reputation: 45104

Some pointers

Compare A and B using sltu or slt instruction (they are not the interchangeable). If the condition is satisfied, then that's all (lazyness). Its probably easier using these instructions to check if B < A act on that.

If not, compare B and D using the bneq or beq instruction. Choose one whether you want to fallthrough or branch to the if's body.

Upvotes: 1

Related Questions