Mohamed Younis CMCS 411, Computer Architecture 1 CMCS 411-101 Computer Architecture Lecture 5 Addressing Mode & Architectural Design Guidelines February.

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

Henk Corporaal TUEindhoven 2011
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.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Lecture 8 Sept 23 Completion of Ch 2 translating procedure into MIPS role of compilers, assemblers, linking, loading etc. pitfalls, conclusions Chapter.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
Chapter 2.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Lecture 8: MIPS Instruction Set
Tuan Tran. What is CISC? CISC stands for Complex Instruction Set Computer. CISC are chips that are easy to program and which make efficient use of memory.
Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
14:332:331 Computer Architecture and Assembly Language Spring 06 Week 4: Addressing Mode, Assembler, Linker [Adapted from Dave Patterson’s UCB CS152 slides.
MIPS Architecture CPSC 321 Computer Architecture Andreas Klappenecker.
1 Lecture 5: MIPS Examples Today’s topics:  the compilation process  full example – sort in C Reminder: 2 nd assignment will be posted later today.
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.
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.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
©UCB CPSC 161 Lecture 5 Prof. L.N. Bhuyan
1 Today  Finish-up procedures/stack  strlen example  Machine language, the binary representation for instructions. —We’ll see how it is designed for.
CDA 3101 Fall 2012 Introduction to Computer Organization Instruction Set Architecture MIPS Instruction Format 04 Sept 2013.
MIPS coding. SPIM Some links can be found such as:
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Instruction Set Architecture
CS35101 Computer Architecture Spring 2006 Week 5 Paul Durand ( Course url:
Computer Architecture Instruction Set Architecture Lynn Choi Korea University.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
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,
Instruction Set Architecture The portion of the machine visible to the programmer Issues: Internal storage model Addressing modes Operations Operands Encoding.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /29/2013 Lecture 13: Compile-Link-Load Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
Oct. 25, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Alternative Instruction Sets * Jeremy R. Johnson Wed. Oct. 25, 2000.
CMPE 325 Computer Architecture II
Csci 136 Computer Architecture II – Summary of MIPS ISA Xiuzhen Cheng
Lecture 04: Instruction Set Principles Kai Bu
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
ECE 15B Computer Organization Spring 2011 Dmitri Strukov Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy,
Csci 136 Computer Architecture II – More on MIPS ISA Xiuzhen Cheng
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Machine Instructions Instruction Formats. Machine Instructions u Internal Signals in computer have high and low voltages which represent values 0 and.
1 Lecture 6: Assembly Programs Today’s topics:  Large constants  The compilation process  A full example  Intro to the MARS simulator.
Instruction Set Architecture Chapter 3 – P & H. Introduction Instruction set architecture interface between programmer and CPU Good ISA makes program.
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Lecture 3 Translation.
Computer Architecture & Operations I
Lecture 6: Assembly Programs
A Closer Look at Instruction Set Architectures
ELEN 468 Advanced Logic Design
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
CS170 Computer Organization and Architecture I
Henk Corporaal TUEindhoven 2010
Computer Architecture
Computer Architecture
COMS 361 Computer Organization
Arrays versus Pointers
CPU Structure CPU must:
Presentation transcript:

Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 5 Addressing Mode & Architectural Design Guidelines February 12, CMSC411.htm

Mohamed Younis CMCS 411, Computer Architecture 2 Lecture’s Overview q Previous Lecture: Instruction set architecture and CPU operations (The stored-program concept) Instruction types, operands and operations (R-type and I-type MIPS instructions format) Decision making and repetition of instruction execution (bne, beq and j instructions) Supporting procedure and context switching (Stack operations, nested procedure call, jal and jr instructions) q This Lecture: Other styles of MIPS addressing Program starting steps Architectural design guidelines

Mohamed Younis CMCS 411, Computer Architecture 3 Constant or Immediate Operands q Use of constants is common in programs, e.g. incrementing an index of an array, counting loop iterations, etc. q In the C compiler "gcc", 52% of arithmetic operands involve constants while in the circuit simulation program "spice" it is 69% q Inefficient support: Use memory address (AddrConstant4) to reference a stored constant lw $t0, AddrConstant4($zero)# $t0 = constant 4 add $sp, $sp, $t0# $sp = $sp + 4 q MIPS handle 16-bit constant efficiently by including the constant value in the address field of an I-type instruction (Immediate-type) addi$sp, $sp, 4#$sp = $sp + 4 q For large constants that need more than 16 bits, a load upper-immediate (lui) instruction is used to concatenate the second part q The compiler or the assembler break large constants into 2 pieces and reassemble them in a register

Mohamed Younis CMCS 411, Computer Architecture 4 Addressing in Branches & Jumps q I-type instructions leaves only 16 bits for address reference limiting the size of the jump q MIPS branch instructions use the address as an increment to the PC allowing the program to be as large as 2 32 (called PC-relative addressing) q Since the program counter gets incremented prior to instruction execution, the branch address is actually relative to (PC + 4) q MIPS also supports an J-type instruction format for large jump instructions q The 26-bit address in a J-type instruct. is concatenated to upper 8 bits of PC

Mohamed Younis CMCS 411, Computer Architecture 5 Summary of MIPS Addressing Modes Concatenation

Mohamed Younis CMCS 411, Computer Architecture 6 Starting a Program - Place code & data modules symbolically in memory -Determine the address of data & instruction labels -Patch both internal & external ref. - Place code & data modules symbolically in memory -Determine the address of data & instruction labels -Patch both internal & external ref. Object files for Unix typically contains: Header: size & position of components Text segment: machine code Data segment: static and dynamic variables Relocation info: identify absolute memory ref. Symbol table: name & location of labels, procedures and variables Debugging info: mapping source to object code, break points, etc. Linker

Mohamed Younis CMCS 411, Computer Architecture 7 Loading Executable Program To load an executable, the operating system follows these steps: Ê Reads the executable file header to determine the size of text and data segments Ë Creates an address space large enough for the text and data Ì Copies the instructions and data from the executable file into memory Í Copies the parameters (if any) to the main program onto the stack Î Initializes the machine registers and sets the stack pointer to the first free location Ï Jumps to a start-up routines that copies the parameters into the argument registers and calls the main routine of the program

Mohamed Younis CMCS 411, Computer Architecture 8 Linking Object Files Assuming the value in $gp is hex

Mohamed Younis CMCS 411, Computer Architecture 9 Other types of Architecture q Accumulator Architecture  Common in early stored-program computers when hardware was so expensive  Machine has only one register (accumulator) involved in all math. & logical operations  All operations assume the accumulator as a source operand and a destination for the operation, with the other operand stored in memory q Extended Accumulator Architecture  Dedicated registers for specific operations, e.g stack and array index registers, added  The 8086 microprocessor is a an example of of such special-purpose register arch. q General-Purpose Register Architecture  MIPS is an example of such arch. where registers are not sticking to play a single role  This type of instruction set can be further divided into:  Register-memory: allows for one operand to be in memory  Register-register (load-store): demands all operand to be in registers

Mohamed Younis CMCS 411, Computer Architecture 10 Other types of Architecture q High-Level-Language Architecture  In the 1960s, systems software was rarely written in high-level languages and virtually every commercial operating system before Unix was written in assembly  Some people blamed the code density on the instruction set rather than the programming language  A machine design philosophy was advocated with the goal of making the hardware more like high-level languages  The effectiveness of high-level languages, memory size limitation and lack of efficient compilers doomed this philosophy to a historical footnote q Reduced Instruction Set Architecture  With the recent development in compiler technology and expanded memory sizes less programmers are using assembly level coding  Instruction set architecture became measurable in the way compilers rather programmable use them  RISC architecture favors simplifying hardware design over enriching instruction offering relying on compilers to effectively use them to perform complex operations  Virtually all new architecture since 1982 follows the RISC philosophy of fixed instruction lengths, load-store operations, and limited addressing mode

Mohamed Younis CMCS 411, Computer Architecture 11 Compact Code and Stack Architectures q When memory is scarce, machines, like Intel 80x86 had variable-length instructions to match varying operand specifications and minimize code size q Stack machines abandoned registers altogether arguing that it is hard for compilers to use them efficiently q Operands are to be pushed on a stack from memory and the results have to be popped from the stack to memory q Operations take their operand by default from the top of the stack and insert the results back onto the stack q Stack machines simplify compilers and lent themselves to a compact instruction encoding q Example:A = B + C Push AddressC# Top=Top+4; Stack[Top]=Memory[AddressC] Push AddressB# Top=Top+4; Stack[Top]=Memory[AddressB] add # Stack[Top-4]=Stack[Top]+Stack[Top-4]; Top=Top-4 Pop AddressA# Memory[AddressA]=Stack[Top]; Top=Top-4 q Compact code is important for heralded network computers where programs must be downloaded over the Internet (e.g. Java-based applications)

Mohamed Younis CMCS 411, Computer Architecture 12 Ê Simplicity favors regularity  Limited number of register formats  Fixed number of operands Ë Smaller is faster  Increased number of registers lengthen signal paths  Signals take longer when travelling farther  increasing clock cycle time  It is not an absolute rule, 31 registers may not be faster than 32 registers  Designers balance the craving of programs for more registers and the desire to keep the clock cycle fast Ì Good design demands good compromises  Fixed length instructions requires different formats for different instructions’ kinds  Group the operation codes of instructions of similar format to simplify decoding  Restrict the variation of different formats to limited number of fields and sort them to a predictable order Í Make the common case fast  Include program counter based addressing to speed up conditional branching  Offer immediate addressing for constant operands Principles of Hardware Designs

Mohamed Younis CMCS 411, Computer Architecture 13 Conclusion q Summary è Various styles of MIPS addressing (Register, displacement, immediate, PC-relative and pseudo-direct) è Program starting steps (Compiler, Assembler, Linker, Loader) è Architectural design guidelines (keep it simple, focus on common cases, smart compromises) q Next Lecture è Number representation è Computer Arithmetic è Addition, Subtraction and logical operations Reading assignment is sections 3.8, 3.9, and 3.15 in text book