lecture 1 - The Hardware/Software Interface 5th Edition...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 2 Instructions: Language of the Computer Instruction Set ! The repertoire of instructions of a computer ! Different computers have different instruction sets ! But with many aspects in common ! Early computers had very simple instruction sets ! Simplified implementation ! Many modern computers also have simple instruction sets §2.1 Introduction The MIPS Instruction Set ! Used as the example throughout the book ! Stanford MIPS commercialized by MIPS Technologies (www.mips.com ) ! Large share of embedded core market ! Applications in consumer electronics, network/ storage equipment, cameras, printers, ! Typical of many modern ISAs ! See MIPS Reference Data tear-out card, and Appendixes B and E Arithmetic Operations ! Add and subtract, three operands ! Two sources and one destination add a, b, c # a gets b + c ! All arithmetic operations have this form ! Design Principle 1: Simplicity favours regularity ! Regularity makes implementation simpler ! Simplicity enables higher performance at lower cost §2.2 Operations of the Computer Hardware
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Arithmetic Example ! C code: f = (g + h) - (i + j); ! Compiled MIPS code: add t0, g, h # temp t0 = g + h add t1, i, j # temp t1 = i + j sub f, t0, t1 # f = t0 - t1 Register Operands ! Arithmetic instructions use register operands ! MIPS has a 32 × 32-bit register file ! Use for frequently accessed data ! Numbered 0 to 31 ! 32-bit data called a ± word ² ! Assembler names ! $t0, $t1, , $t9 for temporary values ! $s0, $s1, , $s7 for saved variables ! Design Principle 2: Smaller is faster ! c.f. main memory: millions of locations §2.3 Operands of the Computer Hardware Register Operand Example ! C code: f = (g + h) - (i + j); ! f, , j in $s0, , $s4 ! Compiled MIPS code: add $t0, $s1, $s2 add $t1, $s3, $s4 sub $s0, $t0, $t1 Memory Operands ! Main memory used for composite data ! Arrays, structures, dynamic data ! To apply arithmetic operations ! Load values from memory into registers ! Store result from register to memory ! Memory is byte addressed ! Each address identifies an 8-bit byte ! Words are aligned in memory ! Address must be a multiple of 4 ! MIPS is Big Endian ! Most-significant byte at least address of a word ! c.f. Little Endian: least-significant byte at least address
Image of page 2
Memory Operand Example 1 ! C code: g = h + A[8]; ! g in $s1, h in $s2, base address of A in $s3 ! Compiled MIPS code: ! Index 8 requires offset of 32 ! 4 bytes per word lw $t0, 32($s3) # load word add $s1, $s2, $t0 offset base register Memory Operand Example 2 ! C code: A[12] = h + A[8]; ! h in $s2, base address of A in $s3 ! Compiled MIPS code: ! Index 8 requires offset of 32 lw $t0, 32($s3) # load word add $t0, $s2, $t0 sw $t0, 48($s3) # store word Registers vs. Memory ! Registers are faster to access than memory ! Operating on memory data requires loads and stores ! More instructions to be executed ! Compiler must use registers for variables as much as possible !
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern