DOC PREVIEW
Berkeley COMPSCI 61C - Lecture Notes

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

PowerPoint PresentationOverview – Instruction RepresentationBig Idea: Stored-Program ConceptConsequence #1: Everything AddressedConsequence #2: Binary CompatibilityInstructions as Numbers (1/2)Instructions as Numbers (2/2)Instruction FormatsR-Format Instructions (1/5)R-Format Instructions (2/5)R-Format Instructions (3/5)R-Format Instructions (4/5)R-Format Instructions (5/5)R-Format Example (1/2)R-Format Example (2/2)AdministriviaI-Format Instructions (1/4)I-Format Instructions (2/4)I-Format Instructions (3/4)I-Format Instructions (4/4)I-Format Example (1/2)I-Format Example (2/2)Peer InstructionIn conclusion…CS61C L13 Introduction to MIPS: Instruction Representation I (1)Garcia © UCBLecturer PSOE Dan Garciawww.cs.berkeley.edu/~ddgarciainst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 13 – Introduction to MIPS Instruction Representation IAnyone seen Terminator? Military wants robot soldiers. Let’s see, they get to grow their budgets, and they intent to (years from now) use Berkeley’s smart dust. Be very afraid. www.nytimes.com/2005/02/16/technology/16robots.htmlCS61C L13 Introduction to MIPS: Instruction Representation I (2)Garcia © UCBOverview – Instruction Representation•Big idea: stored program• consequences of stored program•Instructions as numbers•Instruction encoding •MIPS instruction format for Add instructions•MIPS instruction format for Immediate, Data transfer instructionsCS61C L13 Introduction to MIPS: Instruction Representation I (3)Garcia © UCBBig Idea: Stored-Program Concept•Computers built on 2 key principles:1) Instructions are represented asnumbers.2) Therefore, entire programs can be stored in memory to be read or written just like numbers (data).•Simplifies SW/HW of computer systems: •Memory technology for data also used for programsCS61C L13 Introduction to MIPS: Instruction Representation I (4)Garcia © UCBConsequence #1: Everything Addressed•Since all instructions and data are stored in memory as numbers, everything has a memory address: instructions, data words•both branches and jumps use these•C pointers are just memory addresses: they can point to anything in memory•Unconstrained use of addresses can lead to nasty bugs; up to you in C; limits in Java•One register keeps address of instruction being executed: “Program Counter” (PC)•Basically a pointer to memory: Intel calls it Instruction Address Pointer, a better nameCS61C L13 Introduction to MIPS: Instruction Representation I (5)Garcia © UCBConsequence #2: Binary Compatibility•Programs are distributed in binary form•Programs bound to specific instruction set•Different version for Macintoshes and PCs•New machines want to run old programs (“binaries”) as well as programs compiled to new instructions•Leads to instruction set evolving over time•Selection of Intel 8086 in 1981 for 1st IBM PC is major reason latest PCs still use 80x86 instruction set (Pentium 4); could still run program from 1981 PC todayCS61C L13 Introduction to MIPS: Instruction Representation I (6)Garcia © UCBInstructions as Numbers (1/2)•Currently all data we work with is in words (32-bit blocks):•Each register is a word.•lw and sw both access memory one word at a time.•So how do we represent instructions?•Remember: Computer only understands 1s and 0s, so “add $t0,$0,$0” is meaningless.•MIPS wants simplicity: since data is in words, make instructions be words tooCS61C L13 Introduction to MIPS: Instruction Representation I (7)Garcia © UCBInstructions as Numbers (2/2)•One word is 32 bits, so divide instruction word into “fields”.•Each field tells computer something about instruction.•We could define different fields for each instruction, but MIPS is based on simplicity, so define 3 basic types of instruction formats:•R-format•I-format•J-formatCS61C L13 Introduction to MIPS: Instruction Representation I (8)Garcia © UCBInstruction Formats•I-format: used for instructions with immediates, lw and sw (since the offset counts as an immediate), and the branches (beq and bne), •(but not the shift instructions; later)•J-format: used for j and jal •R-format: used for all other instructions•It will soon become clear why the instructions have been partitioned in this way.CS61C L13 Introduction to MIPS: Instruction Representation I (9)Garcia © UCBR-Format Instructions (1/5)•Define “fields” of the following number of bits each: 6 + 5 + 5 + 5 + 5 + 6 = 326 5 5 5 65opcode rs rt rd functshamt•For simplicity, each field has a name:•Important: On these slides and in book, each field is viewed as a 5- or 6-bit unsigned integer, not as part of a 32-bit integer.•Consequence: 5-bit fields can represent any number 0-31, while 6-bit fields can represent any number 0-63.CS61C L13 Introduction to MIPS: Instruction Representation I (10)Garcia © UCBR-Format Instructions (2/5)•What do these field integer values tell us?•opcode: partially specifies what instruction it is -Note: This number is equal to 0 for all R-Format instructions.•funct: combined with opcode, this number exactly specifies the instruction•Question: Why aren’t opcode and funct a single 12-bit field?-Answer: We’ll answer this later.CS61C L13 Introduction to MIPS: Instruction Representation I (11)Garcia © UCBR-Format Instructions (3/5)•More fields:•rs (Source Register): generally used to specify register containing first operand•rt (Target Register): generally used to specify register containing second operand (note that name is misleading)•rd (Destination Register): generally used to specify register which will receive result of computationCS61C L13 Introduction to MIPS: Instruction Representation I (12)Garcia © UCBR-Format Instructions (4/5)•Notes about register fields:•Each register field is exactly 5 bits, which means that it can specify any unsigned integer in the range 0-31. Each of these fields specifies one of the 32 registers by number.•The word “generally” was used because there are exceptions that we’ll see later. E.g.,-mult and div have nothing important in the rd field since the dest registers are hi and lo-mfhi and mflo have nothing important in the rs and rt fields since the source is determined by the instruction (p. 264 P&H)CS61C L13 Introduction to MIPS: Instruction Representation I (13)Garcia © UCBR-Format Instructions (5/5)•Final field:•shamt: This field contains the amount a shift instruction


View Full Document

Berkeley COMPSCI 61C - Lecture Notes

Documents in this Course
SIMD II

SIMD II

8 pages

Midterm

Midterm

7 pages

Lecture 7

Lecture 7

31 pages

Caches

Caches

7 pages

Lecture 9

Lecture 9

24 pages

Lecture 1

Lecture 1

28 pages

Lecture 2

Lecture 2

25 pages

VM II

VM II

4 pages

Midterm

Midterm

10 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?