CS 61C Summer 2004 Lab 3-1

MIPS Machine Language Instruction Format

Goals

The purpose of this lab is to familiarize yourself with the MIPS machine language instruction format. It is also to help your understanding of PC-relative and absolute addressing.

Background reading

Lecture notes from 7/6 and P&H: Chapters 3.4, 3.8

Part 1: Disassembling Machine Language

Disassemble the following segment of MIPS machine language into assembly language:
0x8c880000
0x8c890004
0x01095021
0x000a5082
0x000a5080
The following information will help you:
op funct
lw 35 X
addu 0 33
srl 0 2
sll 0 0
What does this segment of code do?

Part 2: PC-relative addressing

Run the following MIPS assembly code through MIPSASM:
		beq $0, $0, L1
		sll $0, $0, 0
		sll $0, $0, 0
		sll $0, $0, 0
	L1:
		sll $0, $0, 0	
		sll $0, $0, 0	

Now try altering the distance between the beq instruction and the label L1 by inserting or removing dummy instructions. What portion of the beq machine instruction points to the branch target? What format (R, I, J) is beq? Given this, what does the following machine instruction do?
		0x1000ffff
Is the result what you expected? Why or why not?

Part 3: Pseudodirect addressing

Given that the opcode for jal is 3, what is the hexadecimal machine language representation of the following instruction?
		jal L1
Assume that the instruction is located at address 0x00400000 and L1 is located at address 0x00800080. What would it be if the jal replaced the beq in part 2 above?