MIPS32 (ASM) greater than or equal too, pseudo instruction question

  • Thread starter mr_coffee
  • Start date
  • Tags
    Instruction
In summary, the correct translation for the pseudo instruction "bge $s1, $s2, Lb1" is "slt $t0, $s2, $s1" followed by "beq $t0, $zero, Lb1".
  • #1
mr_coffee
1,629
1
Hello everyone.

I'm trying to figure this questoin out, it says:
We want to tr4anslate the pseduo instruction "bge $s1, $s2, Lb1" into two real MIPS assembly instructions. Which one is correct.

A:
slt $t0, $s2, $s1
beq $t0, $zero, Lb1

B:
slt $t0, $s2, $s1
bne $t0, $zero, Lb1

C:
slt $t0, $s1, $s2
beq $t0, $zero, Lb1

D:
slt $t0, $s1, $s2
bne $t0, $zero, Lb1

slt stands for set on less than
bne means branch if not equal
beq means branch if equal
and bge is the pseudo instruction that means branch if greater than or equal.

I translated each of the following and none seem to be "if greather than or equal too" i only see, if greather than.

A:
slt $t0, $s2, $s1
if($s2 < $s1) $t0 = 1
else $t0 = 0
beq $t0, $zero, Lb1
if($t0 == 0) goto Lb1

B:
slt $t0, $s2, $s1
if($s2 < $s1) $t0 = 1
else $t0 = 0
bne $t0,$zero, Lbl
if( $t0 != 0) goto Lb1

C:
if($s1 < $s2) $t0 = 1
else $t0 = 0;
if($t0 == 0) goto Lb1

D:
if($s1 < $s2) $t0 = 1
else $t0 = 0
if($t0 != 0) goto Lb1;

None of these seem to work, but B looks like it operates as the branch if $s1 > $s2, but not greather than or equal to. ANy help would be great!

thanks!
 
Physics news on Phys.org
  • #2
The correct answer is A. The slt instruction compares two registers and sets the result to 1 if the first register is less than the second, otherwise it sets it to 0. Then the beq instruction checks if that result is 0 and branches if it is. This translates to "branch if $s1 is greater than or equal to $s2".
 
  • #3


I would like to clarify that MIPS32 (ASM) is a specific type of assembly language used for programming microprocessors. It is not a scientific concept or theory. Therefore, I am unable to provide a response to this question based on scientific principles.

However, as a computer scientist, I can offer an explanation for the correct answer. The correct translation for the pseudo instruction "bge $s1, $s2, Lb1" would be option A: slt $t0, $s2, $s1 followed by beq $t0, $zero, Lb1. This is because the slt instruction sets the value of $t0 to 1 if $s2 is less than $s1, and 0 otherwise. This is essentially the same as checking if $s1 is greater than or equal to $s2. The beq instruction then checks if $t0 is equal to 0, indicating that $s1 is not greater than or equal to $s2, and branches to Lb1 if this is the case.

Option B is not correct because it uses the bne instruction, which checks if two values are not equal. This would result in the opposite behavior of the bge instruction, as it would branch if $s1 is less than $s2.

I hope this explanation helps in understanding the correct translation for this pseudo instruction. It is important to note that different assembly languages may have variations in their syntax and instructions, so it is always best to consult the documentation for the specific language being used.
 

Related to MIPS32 (ASM) greater than or equal too, pseudo instruction question

1. What is MIPS32 (ASM)?

MIPS32 (ASM) stands for Microprocessor without Interlocked Pipeline Stages, 32-bit architecture with Assembly Language. It is a type of instruction set architecture used in microprocessors.

2. What does "greater than or equal too" mean in MIPS32 (ASM) pseudo instructions?

"Greater than or equal too" is a comparison operator used in MIPS32 (ASM) pseudo instructions. It compares two values and returns a true value if the first value is greater than or equal to the second value.

3. What are pseudo instructions in MIPS32 (ASM)?

Pseudo instructions in MIPS32 (ASM) are instructions that are not directly implemented in hardware, but are instead translated into one or more actual instructions by the assembler. They are used to simplify programming and make the code more readable.

4. How do I use greater than or equal too in MIPS32 (ASM) pseudo instructions?

To use greater than or equal too in MIPS32 (ASM) pseudo instructions, you would use the "bge" instruction, followed by two operands. For example, "bge $s0, $s1, label" would branch to the label if the value in $s0 is greater than or equal to the value in $s1.

5. What is the purpose of using pseudo instructions in MIPS32 (ASM)?

The purpose of using pseudo instructions in MIPS32 (ASM) is to make programming easier and more efficient. They allow for more readable and concise code, and can also help optimize code by translating into multiple actual instructions.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Programming and Computer Science
Replies
1
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
7K
  • Programming and Computer Science
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
Replies
2
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
Replies
4
Views
20K
  • General Engineering
Replies
1
Views
12K
Back
Top