I'm having difficulty understanding how to translate a JAL (J-Type) instruction in MIPS. Here is the instruction set that I am working on:
0x00400018 add $a0, $a3, $0 = 00E02020
0x0040001C jal L2
0x00400020 L1: jr $ra
0x00400024 L2: sw $s1, 0($s2)
0x00400028 bne $a0, $0, ELSE
0x0040002C j L1
0x00400030 ELSE: addi $a0, $a0, A2
0x00400034 j L2
The first line did not pose a problem, but for the second line, I am entirely unsure how to translate jal L2. Using the MIPS reference sheet, I see that to get the address, I need to perform R[31]=PC+8;PC=JumpAddr.
J-Type Instructions are opcode/6bit and address 26bit so the first 6bit are 00 0011 but I don't know how I get the remaining 26bit. Any help would be appreciated.
lower_26_bits = instruction_word & 0x3FFFFFF;
. – Michael