1 / 16

# CS61C – Discussion 0b100 MIPS Instructions - PowerPoint PPT Presentation

CS61C – Discussion 0b100 MIPS 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

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

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

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

• 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

MAL vs TAL

• MAL: MIPS Assembly Language

• Includes pseudoinstructions

• TAL: True Assembly Language

• Instructions are numbers too!

• 32 bits, in fact

• PC – program counter

• Register of the currently running instruction

• 3 Types of instructions:

• R

• I

• J

• Different type means different fields

• Most important field?

• 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

• opcode= 8

• rs (source) = 22

• rt (target) = 21

• immediate = -50

• Read the opcodeof the instruction

• Using green sheet, determine instruction type

• Decode the fields

• Convert to assembly!

• 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!

• Work on 4 and 5 in the back

• 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 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}