1 / 16

CS61C – Discussion 0b100 MIPS Instructions

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

armani
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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS61C – Discussion 0b100MIPS Instructions

  2. Worksheet Time • Get started with the first and last problem on the front • Work with a (new!) partner, please

  3. 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)

  4. MAL vs TAL • MAL: MIPS Assembly Language • Includes pseudoinstructions • TAL: True Assembly Language

  5. Machine Code • Instructions are numbers too! • 32 bits, in fact • PC – program counter • Register of the currently running instruction

  6. Instruction Types • 3 Types of instructions: • R • I • J • Different type means different fields • Most important field?

  7. Instruction Fields

  8. 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)

  9. Encoding MIPS Machine Code • Get opcode for instruction type • Convert arguments into fields • Order the fields correctly • Convert to binary, hex, or decimal

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

  11. Decoding MIPS Machine Code • Read the opcodeof the instruction • Using green sheet, determine instruction type • Decode the fields • Convert to assembly!

  12. 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!

  13. Worksheet Time • Work on 4 and 5 in the back

  14. 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)

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

  16. Don’t stress – it’s on the sheet

More Related