Describe what happens when the following instructions execut

Describe what happens when the following instructions execute:

a) BNE $s1, $s2, Loop

b) JAL 0x00400070

Solution

a) BNE $s1,$s2,Loop:

BNE is Branch if not equal instruction. This instruction branches or jumps to the address specified if and only if zero flag is clear i.e here if $s1 and $s2 are not equal then conditions becomes true and zero flag is clear and so the processor jumps to execution of Loop mentioned above.

If zero flag is set i.e if $s1 is not equal to $s2 then condition becomes false and zero flag is set that is it is not clear therefore the processor will execute the next instuction after BNE rather than jumping or branching to Loop.

b) JAL 0x00400070:

JAL is a jump and link instruction which jumps to a subroutine and saves the address of the next instuction in the return address register $ra to maintain the link between the subroutine and the original call in the program.

So,In the above given instruction, the processor will jump to subroutine at address 0x00400070 and after execution will return back to next instruction after JAL in the original main program whose address has been stored by JAL instruction in the register $ra which is the return address register which allows to continue execution where it was left by JAL.

Describe what happens when the following instructions execute: a) BNE $s1, $s2, Loop b) JAL 0x00400070Solutiona) BNE $s1,$s2,Loop: BNE is Branch if not equal in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site