Computer Architecture - The Instruction Set The Course’s Goals  To be interesting and fun. An interested student learns more.  To answer questions that.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

Goal: Write Programs in Assembly
Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
Chapter 2 Instructions: Language of the Computer
Chapter 2 Instructions: Language of the Computer Part III.
CS2100 Computer Organisation MIPS Part III: Instruction Formats (AY2014/2015) Semester 2.
Assembly Language II CPSC 321 Andreas Klappenecker.
1 Warning! Unlike the previous lessons, for today's lesson you will have to listen, think and even understand (for the exam, of course). Individuals with.
MIPS Architecture CPSC 321 Computer Architecture Andreas Klappenecker.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
Computer Structure - The Instruction Set (2) Goal: Implement Functions in Assembly  When executing a procedure (function in C) the program must follow.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Instruction Representation II (1) Fall 2005 Lecture 10: Instruction Representation II.
ECE 232 L5 Assembl.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 5 MIPS Assembly.
MIPS Instruction Set Advantages
ISA-2 CSCE430/830 MIPS: Case Study of Instruction Set Architecture CSCE430/830 Computer Architecture Instructor: Hong Jiang Courtesy of Prof. Yifeng Zhu.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
1  1998 Morgan Kaufmann Publishers Machine Instructions: Language of the Machine Lowest level of programming, control directly the hardware Assembly instructions.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture 4: MIPS Instruction Set
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
CMPE 325 Computer Architecture II
CHAPTER 6 Instruction Set Architecture 12/7/
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
Computer Organization Rabie A. Ramadan Lecture 3.
CENG 311 Instruction Representation
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Computer Organization Instructions Language of The Computer (MIPS) 2.
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
Lecture 17: 10/31/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
MIPS Assembly.
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
COMPUTER ARCHITECTURE & OPERATIONS I
Instruction Set Architecture
Computer Architecture Instruction Set Architecture
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
CS170 Computer Organization and Architecture I
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Computer Architecture & Operations I
MIPS Instruction Encoding
ECE232: Hardware Organization and Design
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
Part II Instruction-Set Architecture
COMS 361 Computer Organization
COMS 361 Computer Organization
MIPS Coding Continued.
Instruction Set Architecture
Presentation transcript:

Computer Architecture - The Instruction Set The Course’s Goals  To be interesting and fun. An interested student learns more.  To answer questions that are probably keeping you awake at night: What is a Super- Scalar machine? How does branch prediction work? What does ILP stand for?  For you to write better programs. By understanding how your program is executed on a computer, will enable you to program better. 1/16

Computer Architecture - The Instruction Set Not the Course’s Goals b o r i n g  To be b o r i n g. A bored student: a. Fall asleep, that’s OK just don’t snore. b. Talks, that’s not OK.  To answer questions that aren’t related to computers: “Will George Clooney return to ER” has nothing to due with the course.  For you to design computers. But after this course you will have the necessary basics. 2/16

Computer Architecture - The Instruction Set General Information  Contact is by phone ( (jct), (hu), (home) ),or in person (look at my home page for details).  Grade: the final grade is composed of a final exam (70%) and three mini-exams (30%), out of which the 2 best will be used.  Assignments are optional. They will be given in the same format as the mini-exams. 3/16

Computer Architecture - The Instruction Set What is Computer Architecture?  Computer Architecture (CA) is to a computer what classic architecture is to a building.  Classic Architecture  Computer Architecture 4/16

Computer Architecture - The Instruction Set  Computer Architecture (CA) is to a computer what classic architecture is to a building.  The computer architect designs the functional properties of a microprocessor.  With this plan the hardware engineer designs the gates, bits, and lines that implement the processor. If there are problems in implementing the architect’s plan the engineer returns the plan to the architect with suggested modifications.  A computer then translates this plan to the actual transistors laid out on the chip.  Instruction Set Architecture (ISA) is one level above the architecture described above. The machine language of the processor defines the architecture. Processors that are binary compatible are said to have the same architecture.  Examples are the Intel x86 family, MIPS RxK family etc.

Computer Architecture - The Instruction Set Instruction Set Architecture (ISA)  The machine language instruction: add $s0,$s1,$s2 defines the machines architecture. Addition is performed between 2 registers and the result is placed in a 3rd register.  How this is performed is the implementation of the processor.  Confused? Not for long. In this lesson we will define the Instruction Set Architecture of a modern RISC processor. 5/16

Computer Architecture - The Instruction Set The MIPS ISA  The instruction set we will study is the instruction set of the family of processors. Used mainly in the computers of Silicon Graphics but also in the products of Nintendo and Sony.  RISC - Reduced Instruction Set Computer, also called a Load/Store machine. 6/16

Computer Architecture - The Instruction Set  A RISC processor has the following traits:  All instructions perform operations between registers. The operands are in registers and the result is written into a register.  The exceptions are the load and store instructions. Data is loaded from memory into a register, or data is stored from a register into memory.  All instructions are the same length, 32-bits, which is the length of the word of the machine.  The number of possible instruction types is reduced. This is due to the fact that the opcode field of the instruction is limited in size, thus the number of instructions is limited.  On the other hand a Complete Instruction Set Computer (CISC) such as the Intel x86 family (486,Pentium, Pentium II, …) :  Can perform operations between registers and memory.  Has variable length instructions (from 1 byte and upwards).  Has a “complete” set of instructions.  Is much more harder to implement as we will see in future lessons.

Computer Architecture - The Instruction Set R-Format Instructions  a=b+c; compiles into: add $s0,$s1,$s2  R-Format instructions use 3 registers: add $s0,$s1,$s2 # $s0 = $s1+$s2 sub $s1,$s4,$s5 # $s1 = $s4-$s5 or $t0,$t0,$t1 # $t0 = $t0|$t1 slt $t5,$a1,$a2 # $t5 = $a1<$a2 sllv $a0,$s1,$s2 # $a0 = $s1<<$s2 sll $a0,$s1,3 # $a0 = $s1<<3  The R-Format instructions include most of the arithmetic and logical instructions. 7/16

Computer Architecture - The Instruction Set MIPS Instruction Fields MIPS instruction fields are given names: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits  op: basic operation of the instruction called opcode  rs: first register source operand  rt: second register source operand  rd: destination register, gets the result of the op  shamt: shift amount, used in shift instructions.  funct: selects the specific variant of the operation. 8/16

Computer Architecture - The Instruction Set Load/Store Instructions  Are the only instructions that  char a,b,A[100]; access memory. a = b + A[8]; will compile into: lw$t0, 8($s3) # $s3 holds the # address of A add $s1,$s2,$t0  int a,b,A[100]; A[6] = b; will compile into: sw $s2,24($s3)  lw - load word, sw - store word 9/16

Computer Architecture - The Instruction Set  The constant in a data transfer instruction is called the offset and the register the base register.  Lets look at another example: a = A[6] + A[8]; will compile into: lw$t0, 8($s3) # $s3 holds the lw$t1, 6($s3) # address of A add $s1,$t1,$t0  The above code is true if all variables are chars, ints of 1 byte. But if the variables are ints of 4 bytes?  The code is now: lw$t0, 32($s3) # $s3 holds the lw$t1, 24($s3) # address of A add $s1,$t1,$t0  The offset is always in bytes, the compiler translates offsets in ints in the C++ program to offsets in bytes in assembly language.

Computer Architecture - The Instruction Set I-format Instructions  The I stand for Immediate, the instruction contains a number. In the case of load/store instructions it is the offset from the base register.  op rs rt address 6 bits 5 bits 5 bits 16 bits  Lets look at a load instruction: lw $t0,32($s3) # $t0 = A[8]  rs: base address register ($s3 )  rt: destination register ($t0 )  address: offset of to 2 15 bytes ( 32 ) 10/16

Computer Architecture - The Instruction Set Branchs if(i==j) f=g+h; else f=g-h; bne $s3,$s4,Else add $s0,$s1,$s2 j Exit Else: sub $s0,$s1,$s2 Exit: The j instruction (j for jump) is an unconditional branch instruction. 11/16

Computer Architecture - The Instruction Set  Decision making is possible using branches (הסתעפויות).  The following instructions are conditional branch instructions:  beq reg1,reg2,L1 #branch equal goto the instruction labeled L1 if the register values are equal, if unequal goto the next instruction.  bne reg1,reg2,L1 #branch not equal goto the instruction labeled L1 if the register values are’nt equal, if equal goto the next instruction.  The branch instructions are of the I-format instruction. The label is an immediate value.  The j instruction (j for jump) is an unconditional branch instruction. The machine always follows the branch. j is of the J-format, 6 bits for opcode and 26 for the jump address.

Computer Architecture - The Instruction Set Addressing in Branchs and Jumps  j # go to location Jumps to the address in memory bits (opcode) 26 bits (address)  bne $s0,$s1,Exit # branch if $s0!=$s Exit 6 bits 5 bits 5 bits 16 bits (address)  Addresses of the program have to fit into a 16-bit field.  Thus no program could be larger than 64KByte which is unrealistic. 12/16

Computer Architecture - The Instruction Set Branch Offset in Machine Language  Lets look at a loop in assembly: Loop:.. bne $t0,$t1,Exit subi $t0,$t0,1 j Loop Exit:  The machine code of the bne instruction is:  The branch instruction adds 8 bytes to the PC and not 12 because the PC is automatically incremented by 4 when an instruction is executed. 13/16

 The Program Counter (PC) is a register the software can't access directly, that always contains the address of the current instruction being executed. Thus if we use the PC as the register to add to the branch address we can always branch within a range of to 2 15 bytes of the current instruction.  This is enough for most loops and if statements. This form of addressing is called PC-relative addressing.  Procedures are not usually within a short range of the current instruction and thus jal is a J-type instruction.  Loop:. bne $t0,$t1,Exit subi $t0,$t0,1 j Loop Exit:  The branch instruction adds 8 bytes to the PC and not 12 because the PC is automatically incremented by 4 when an instruction is executed.  In fact the branch offset is 2 not 8. All MIPS instructions are 4 bytes long thus the offset is in words not bytes. The range of a branch has been multiplied by 4.

Computer Architecture - The Instruction Set Pseudodirect Addressing  The 26-bit field in the jump instruction is also a word address. Thus it is a 28-bit address. But the PC holds 32-bits?  The MIPS jumps instruction replaces only the lower 28 bits of the PC, leaving the 4 highest bits of the PC unchanged.  The loader and linker must avoid placing a program across an address boundary ( גבול ) of 256MB (64 million instructions). Otherwise a j must be replaced with a jr. 14/16

Computer Architecture - The Instruction Set Addressing Mode Summary  Immediate addressing - the Operand is a constant  Register addressing - the Operand is a register  Base or displacement addressing - the operand is at the memory location whose address is the sum of a register and a constant in the instruction.  PC-relative addressing - the address is the sum of the PC and a constant in the instruction.  Pseudodirect addressing - the jump address is the 26 bits of the instruction concatenated ( מצורף ) to the upper bits of the PC. 15/16

 Immediate addressing - the Operand is a constant addi $t0,$t1,102 # $t0=$t andi $s0,$s0,16 # $s0=$s0 & 16  Register addressing - the Operand is a register addi $t0,$t1,102 andi $s0,$s0,16 jr $s4 # jump to the address in $s4  Base or displacement addressing - the operand is at the memory location whose address is the sum of a register and a constant in the instruction. lw $t0,20($gp) # $t0 = $gp[5] lb $t1,7($s5) # $t0 = $s5[7]  PC-relative addressing - the address is the sum of the PC and a constant in the instruction. beg $s0,$s1,Label # if $s0<$s1 jump to Label  Pseudodirect addressing - the jump address is the 26 bits of the instruction concatenated ( מצורף ) to the upper bits of the PC. j L37 jal strcmp

Computer Architecture - The Instruction Set Addressing Modes (picture) 16/16