# lecture 4 - Chapter 2 Instructions Language of the Computer...

• Test Prep
• nnahar
• 62

This preview shows pages 1–10. Sign up to view the full content.

Chapter 2 Instructions: Language of the Computer

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

Chapter 2 — Instructions: Language of the Computer — 2 Instruction Set n The repertoire of instructions of a computer n Different computers have different instruction sets n But with many aspects in common n Early computers had very simple instruction sets n Simplified implementation n Many modern computers also have simple instruction sets §2.1 Introduction
Chapter 2 — Instructions: Language of the Computer — 3 The MIPS Instruction Set n Used as the example throughout the book n Stanford MIPS commercialized by MIPS Technologies ( ) n Large share of embedded core market n Applications in consumer electronics, network/storage equipment, cameras, printers, n Typical of many modern ISAs n See MIPS Reference Data tear-out card, and Appendixes A and E

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

Chapter 2 — Instructions: Language of the Computer — 4 Arithmetic Operations n Add and subtract, three operands n Two sources and one destination add a, b, c # a gets b + c n All arithmetic operations have this form n Design Principle 1: Simplicity favours regularity n Regularity makes implementation simpler n Simplicity enables higher performance at lower cost §2.2 Operations of the Computer Hardware
Chapter 2 — Instructions: Language of the Computer — 5 Arithmetic Example n C code: f = (g + h) - (i + j); n 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

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

Chapter 2 — Instructions: Language of the Computer — 6 Register Operands n Arithmetic instructions use register operands n MIPS has a 32 × 32-bit register file n Use for frequently accessed data n Numbered 0 to 31 n 32-bit data called a word n Assembler names n \$t0, \$t1, , \$t9 for temporary values n \$s0, \$s1, , \$s7 for saved variables n Design Principle 2: Smaller is faster n c.f. main memory: millions of locations §2.3 Operands of the Computer Hardware
Chapter 2 — Instructions: Language of the Computer — 7 Register Operand Example n C code: f = (g + h) - (i + j); n f, , j in \$s0, , \$s4 n Compiled MIPS code: add \$t0, \$s1, \$s2 add \$t1, \$s3, \$s4 sub \$s0, \$t0, \$t1

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

Chapter 2 — Instructions: Language of the Computer — 8 Memory Operands n Main memory used for composite data n Arrays, structures, dynamic data n To apply arithmetic operations n Load values from memory into registers n Store result from register to memory n Memory is byte addressed n Each address identifies an 8-bit byte n Words are aligned in memory n Address must be a multiple of 4 n MIPS is Big Endian n Most-significant byte at least address of a word n c.f. Little Endian: least-significant byte at least address
Chapter 2 — Instructions: Language of the Computer — 9 Memory Operand Example 1 n C code: g = h + A[8]; n g in \$s1, h in \$s2, base address of A in \$s3 n Compiled MIPS code: n Index 8 requires offset of 32 n 4 bytes per word lw \$t0, 32(\$s3) # load word add \$s1, \$s2, \$t0 offset base register

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

This is the end of the preview. Sign up to access the rest of the document.
• Fall '13
• X86, MIPS architecture, Machine code, n

{[ snackBarMessage ]}

### What students are saying

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

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

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

Dana University of Pennsylvania ‘17, Course Hero Intern

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

Jill Tulane University ‘16, Course Hero Intern