Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2006 1 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions.

Similar presentations


Presentation on theme: "Fall 2006 1 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions."— Presentation transcript:

1 Fall 2006 1 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions

2 Fall 2006 2 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Last time MIPS assembly language Arithmetic and logic instructions Load and store instructions

3 Fall 2006 3 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Write the program?

4 Fall 2006 4 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Lets run the program

5 Fall 2006 5 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Instruction Classes Arithmetic and logic (some more) Load: li, la, lbu, lw Store: sb, sw Comparison Branch and jump Data Movement Floating Point √ √

6 Fall 2006 6 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Arithmetic and Logic InstructionExampleMeaning Andand $s1, $s2, $s3$s1 = $s2 & $s3 And immediateandi $s1, $s2, 100$s1 = $s2 & 100 Oror $s1, $s2, $s3$s1 = $s2 | $s3 Or immediateori $s1, $s2, 100$s1 = $s2 | 100 Shift left logicalsll $s1, $s2, 10$s1 = $s2 << 10 Shift right logicalsrl $s1, $s2, 10$s1 = $s2 >> 10 Only registers used for operands

7 Fall 2006 7 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Instruction Classes Arithmetic and logic: add, sub, and, or Load: li, la, lbu, lw Store: sb, sw Comparison Branch and jump Data Movement Floating Point √ √ √

8 Fall 2006 8 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Branch and Jump InstructionExampleMeaning Branch on equalbeq $s1, $s2, 100If ($s1 = = $s2 ) go to (PC +4 )+ 100 Branch on not equalbne $s1, $s2, 100If ($s1 ! = $s2 ) go to (PC +4 )+ 100 Jumpj loopGo to loop: Jump and linkjal subroutine$ra = PC + 4, go to subroutine Jump Registerjr $raPC = $ra

9 Fall 2006 9 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Loops in assembly Initialize loop counter Modify counter (decrement, increment) Check if counter = = end condition –True, leave loop –False, continue with loop Body of loop Continue with next pass in loop

10 Fall 2006 10 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Flowchart of loop count = 5 count -- count = = 0 ? Body of loop no yes Body could go ahead of test

11 Fall 2006 11 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Loops NOTE: you may place the check after the body How many times is “body” executed? (4 or 5?

12 Fall 2006 12 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Lets run the program

13 Fall 2006 13 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Write the program? Write a loop that adds 4 to $t2, six times

14 Fall 2006 14 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Machine Instructions Definition: numeric (hex) versions of instruction Memory: contains binary number or machine instruction, it’s what the hardware executes Formats –R, register –I, immediate –J, jump NOTE: Result of assembly is a machine instruction

15 Fall 2006 15 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Instruction Formats NameFields Size 6 bits5 bits 6 bits R typeoprsrtrdshamtfunct I typeoprsrtaddress/immediate J typeoptarget address All instructions are 32-bits long 32-bits

16 Fall 2006 16 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering R-format Operation (op) code All 0x00; exception mfc0 = 0x10, Funct determines specific instruction add = 0x20, sub = 0x22, mult = 0x18, div = 0x1a Operands –rd = destination register –rs = first argument –rt = second argument Shamt = shift amount

17 Fall 2006 17 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering R-format example R typeFields Size 6 bits5 bits 6 bits R typeoprsrtrdshamtfunct 00 00000 00110 01000 00100 000010 0000 add$2, $3, $4 addrd, rs, rt 0000 0000 0110 0100 0001 0000 0010 0000 0x 0064 1020

18 Fall 2006 18 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Find machine instruction? 0x00d05022 R typeFields Size 6 bits5 bits 6 bits R typeoprsrtrdshamtfunct 00 00000 01101 00000 10100 000010 0010 sub$10, $6, $16 sub rd, rs, rt

19 Fall 2006 19 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering I-format Op code examples lw = 0x23, sw = 0x2b, beq = 0x04 Operands –rs = first argument –rt = second argument Immediate = sign extended bits [15 – 0]

20 Fall 2006 20 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering I-format example lw$2, 100($3) lwrt, adr (rs) 1000 1100 0110 0010 0000 0000 0110 0100 0x 8c62 0064 NameFields Size 6 bits5 bits 16 bits I typeoprsrtaddress/immediate 10 00110 00110 00100000 0000 0110 0100

21 Fall 2006 21 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Find machine instruction? NameFields Size 6 bits5 bits 16 bits I typeoprsrtaddress/immediate 1010110 10001 01000000 0000 0100 0000 sw$20, 64($8) swrt, adr (rs) 0xad14 0040

22 Fall 2006 22 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering

23 Fall 2006 23 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Write the program? Write a loop that adds 4 to $t2, six times

24 Fall 2006 24 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Find machine instruction? 0x 00d0 5022 R typeFields Size 6 bits5 bits 6 bits R typeoprsrtrdshamtfunct 00 00000 01101 00000 10100 000010 0010 sub$10, $6, $16 sub rd, rs, rt

25 Fall 2006 25 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Find machine instruction? NameFields Size 6 bits5 bits 16 bits I typeoprsrtaddress/immediate 10 10110 10001 01000000 0000 0100 0000 sw$20, 64($8) swrt, adr (rs) 0x ad14 0040


Download ppt "Fall 2006 1 EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions."

Similar presentations


Ads by Google