MIPS Team - Build BEQ

I copied the job image I have on MIPS - Aseembly.

I understand (I think) what is going on in the code before the line:

beq $11, $0, 3

      

I understand that the code now makes a PC-RELATIVE branch for the address:

PC+4+3*4 

      

But I don't understand how it goes in this code right here - which next line should be canceled?

I'll make my question clearer:

Row 1: adds 15 to zero, puts it in $a0 register.

Row 2: ANDs $a0 register with 3, puts the result in $a0.

Row 3: ORs $a0 register with 22, puts the result in $a0.

Row 4: shifts $a0 to the left by 5 bits. Result - in $a0.

Row 5: if $a0 equals $a0, go to PC+4+6*24 address. The address is Row 7 which is:

slt $11, $10, $9

      

Which puts the value 0 in the $ t3 register, because $ 10 = $ 9.

Now I get into ROW 8:

beq $11, $0, 3.

      

What does line 8 do?

Any help is assigned.

Direct link to my image - click if you can't read it correctly.

enter image description here

+3


source to share


1 answer


beq $11, $0, 3

means the transition to the third team forward from beq

if $11 == $0

. For example:

beq $11, $0, 3
instruction 1
instruction 2
instruction 3 < the target

      

the number 3

will be the first sign extension and then added to the program counter $pc

as:

$pc = $pc + 3 * 4 

      



or simply:

$pc = $pc + 3 << 2

      

4

is that each MIPS instruction is 4 bytes in size.

+1


source







All Articles