Cs61c discussion 0b100 mips instructions
This presentation is the property of its rightful owner.
Sponsored Links
1 / 16

CS61C – Discussion 0b100 MIPS Instructions PowerPoint PPT Presentation


  • 71 Views
  • Uploaded on
  • Presentation posted in: General

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

Download Presentation

CS61C – Discussion 0b100 MIPS Instructions

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 0b100 mips instructions

CS61C – Discussion 0b100MIPS Instructions


Worksheet time

Worksheet Time

  • Get started with the first and last problem on the front

  • Work with a (new!) partner, please


Pseudo instructions

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 vs TAL

  • MAL: MIPS Assembly Language

    • Includes pseudoinstructions

  • TAL: True Assembly Language


Machine code

Machine Code

  • Instructions are numbers too!

    • 32 bits, in fact

  • PC – program counter

    • Register of the currently running instruction


Instruction types

Instruction Types

  • 3 Types of instructions:

    • R

    • I

    • J

  • Different type means different fields

    • Most important field?


Instruction fields

Instruction Fields


Instruction types1

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

Encoding MIPS Machine Code

  • Get opcode for instruction type

  • Convert arguments into fields

  • Order the fields correctly

  • Convert to binary, hex, or decimal


Example

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

Decoding MIPS Machine Code

  • Read the opcodeof the instruction

  • Using green sheet, determine instruction type

  • Decode the fields

  • Convert to assembly!


Announcements

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 time1

Worksheet Time

  • Work on 4 and 5 in the back


Beq and bne

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


Don t stress it s on the sheet

Don’t stress – it’s on the sheet


  • Login