go to previous page   go to home page   hear noise   go to next page

Answer:

AddressMachine Instruction Assembly Instruction
004000000000 0000 0000 0000 0000 0000 0000 0000sll $0,$0,0
004000040000 0000 0000 0000 0000 0000 0000 0000sll $0,$0,0
004000080000 0000 0000 0000 0000 0000 0000 0000sll $0,$0,0
0040000C0000 0000 0000 0000 0000 0000 0000 0000sll $0,$0,0
00400010000010 00 0001 0000 0000 0000 0000 0000j firstInstruction
004000140000 0000 0000 0000 0000 0000 0000 0000sll $0,$0,0


1. Write the jump address
0x00400000 as 32 bits
2. Write the 26-bit field
of the jump instruction:
3. Shift it left two positions:
4. What are the high-order
four bits of the PC?
5. Copy (4) to the left of (3):
6. Is (5) the same as (1)?

Symbolic Address

How do you know what the high-order four bits of the PC are? Well, since you have the address of the instruction following the jump instruction, you know that its address is in the PC. So the high order four bits come from that address.

Usually the high order four bits of the address of the jump instruction and of the one following it are the same. But in very rare instances they might be different (when adding four to the jump instruction's address causes a carry into the high order bits).

With some trickery, a 26-bit field can specify a 32-bit address. But it is a nuisance to figure out! If you were doing machine language programming, that is what you would have to do. But the assembler does the work for you. Here is a tiny program:

## jump.asm
##
      .text
      .globl  main

main: 
      sll    $0,$0,0
      sll    $0,$0,0
      sll    $0,$0,0
      sll    $0,$0,0
      j      main
      addiu $8,$8,1 
      
## End of file

It is similar to the previous example. The symbolic address main stands for the address of the first instruction. The instruction   j main   tells the assembler to assemble a machine instruction with the proper 26-bit field so that control is transferred to main.

The branch delay slot is filled with an instruction that increments register $8.


QUESTION 8:

After the loop has executed five times, what value will be in register $8? SPIM initializes all registers to zero when a program starts.