Loading in 5 sec....

CS61C – Discussion 0b100 MIPS InstructionsPowerPoint Presentation

CS61C – Discussion 0b100 MIPS Instructions

- 103 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' CS61C – Discussion 0b100 MIPS Instructions' - armani

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### CS61C – Discussion 0b100MIPS Instructions

Worksheet Time

- Get started with the first and last problem on the front
- Work with a (new!) partner, please

Pseudo-instructions

- Something in C translate awkwardly in MIPS
- a = b; add $s0, $s1, $0

- Pseudo-instructions make assembly programming easier, but get translated later
- move $s0 $s1

- Some common pseudo-instructions:
- move
- li (load immediate)
- la (load address)

MAL vs TAL

- MAL: MIPS Assembly Language
- Includes pseudoinstructions

- TAL: True Assembly Language

Machine Code

- Instructions are numbers too!
- 32 bits, in fact

- PC – program counter
- Register of the currently running instruction

Instruction Types

- 3 Types of instructions:
- R
- I
- J

- Different type means different fields
- Most important field?

Instruction Types

- I Type instructions
- Immediates
- lw/sw
- beq/bne

- J type instructions
- j and jal, but not jr

- R type instructions
- Everything else, including shifts (sll, srl)

Encoding MIPS Machine Code

- Get opcode for instruction type
- Convert arguments into fields
- Order the fields correctly
- Convert to binary, hex, or decimal

Example

- addi $s5, $s6, -50
- addi $21, $22, -50
- addi is I-type
- opcode= 8
- rs (source) = 22
- rt (target) = 21
- immediate = -50

Decoding MIPS Machine Code

- Read the opcodeof the instruction
- Using green sheet, determine instruction type
- Decode the fields
- Convert to assembly!

Announcements

- Proj 1-1 due 09/24 23:59
- Proj 1-2 due 10/01 23:59
- HW3: Floating Point and Caches
- Due 10/05 23:59

- Midterm coming up soonish
- Lots of old MT on HKN site!

Worksheet Time

- Work on 4 and 5 in the back

BEQ and BNE

- Offset is relative to PC + 4
- We interpret immediate as two’s complement offset to PC
- 16 bits
- But we know next instruction will end in 00 so we don’t include it

- So it’s really like 18 bits
- Signed means +- 217 bytes around PC

- Formula: (PC+4) + (immediate * 4)

JUMP AROUND

- Jump instructions use absolute addresses
- Again, next address will always end in 00
- We take the top 4 bits from PC + 4
- So formula is:{PC+4, 26 bits, 00}

Download Presentation

Connecting to Server..