Introduction ICS 233 Computer Architecture and Assembly Language
Introduction ICS 233 Computer Architecture and Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals
Presentation Outline v Welcome to ICS 233 v High-Level, Assembly-, and Machine-Languages v Components of a Computer System v Chip Manufacturing Process v Technology Improvements v Programmer's View of a Computer System Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 2
Welcome to ICS 233 v Instructor: Dr. Muhamed F. Mudawar v Office: Building 22, Room 328 v Office Phone: 4642 v Office Hours: SMW 10: 00 am – 12 noon v Course Web Page: ² http: //www. ccse. kfupm. edu. sa/~mudawar/ics 233/ v Email: ² mudawar@kfupm. edu. sa Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 3
Which Textbooks will be Used? v Computer Organization & Design: The Hardware/Software Interface ² Third Edition ² David Patterson and John Hennessy ² Morgan Kaufmann Publishers, 2005 v MIPS Assembly Language Programming ² Robert Britton ² Pearson Prentice Hall, 2004 ² Supplement for Lab v Read the textbooks in addition to slides Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 4
Grading Policy v Laboratory 20% v Assignments and Quizzes 10% v Projects 20% v Midterm Exam I 15% v Midterm Exam II 15% v Final Exam Introduction 20% ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 5
Software Tools v MIPS Simulators ² MARS: MIPS Assembly and Runtime Simulator § Runs MIPS-32 assembly language programs § Website: http: //courses. missouristate. edu/Ken. Vollmar/MARS/ ² PCSPIM § Also Runs MIPS-32 assembly language programs § Website: http: //www. cs. wisc. edu/~larus/spim. html v CPU Design and Simulation Tool ² Logisim § Educational tool for designing and simulating CPUs § Website: http: //ozark. hendrix. edu/~burch/logisim/ Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 6
Course Objectives v Towards the end of this course, you should be able to … ² Describe the instruction set architecture of a MIPS processor ² Analyze, write, and test MIPS assembly language programs ² Describe organization/operation of integer & floating-point units ² Design the datapath and control of a single-cycle CPU ² Design the datapath/control of a pipelined CPU & handle hazards ² Describe the organization/operation of memory and caches ² Analyze the performance of processors and caches v Required Background ² Ability to program confidently in Java or C ² Ability to design a combinational and sequential circuit Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 7
What is “Computer Architecture” ? v Computer Architecture = Instruction Set Architecture + Computer Organization v Instruction Set Architecture (ISA) ² WHAT the computer does (logical view) v Computer Organization ² HOW the ISA is implemented (physical view) v We will study both in this course Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 8
Next. . . v Welcome to ICS 233 v High-Level, Assembly-, and Machine-Languages v Components of a Computer System v Chip Manufacturing Process v Technology Improvements v Programmer's View of a Computer System Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 9
Some Important Questions to Ask v What is Assembly Language? v What is Machine Language? v How is Assembly related to a high-level language? v Why Learn Assembly Language? v What is an Assembler, Linker, and Debugger? Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 10
A Hierarchy of Languages Application Programs High-Level Languages Machine independent High-Level Language Machine specific Low-Level Language Assembly Language Machine Language Hardware Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 11
Assembly and Machine Language v Machine language ² Native to a processor: executed directly by hardware ² Instructions consist of binary code: 1 s and 0 s v Assembly language ² Slightly higher-level language ² Readability of instructions is better than machine language ² One-to-one correspondence with machine language instructions v Assemblers translate assembly to machine code v Compilers translate high-level programs to machine code ² Either directly, or ² Indirectly via an assembler Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 12
Compiler and Assembler Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 13
Translating Languages Program (C Language): A statement in a high-level language is translated typically into several machine-level instructions swap(int v[], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } Compiler MIPS Machine Language: MIPS Assembly Language: sll add lw lw sw sw jr $2, $5, 2 $2, $4, $2 $15, 0($2) $16, 4($2) $16, 0($2) $15, 4($2) $31 Introduction Assembler 00051080 00821020 8 C 620000 8 CF 20004 ACF 20000 AC 620004 03 E 00008 ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 14
Advantages of High-Level Languages v Program development is faster ² High-level statements: fewer instructions to code v Program maintenance is easier ² For the same above reasons v Programs are portable ² Contain few machine-dependent details § Can be used with little or no modifications on different machines ² Compiler translates to the target machine language ² However, Assembly language programs are not portable Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 15
Why Learn Assembly Language? v Many reasons: ² Accessibility to system hardware ² Space and time efficiency ² Writing a compiler for a high-level language v Accessibility to system hardware ² Assembly Language is useful for implementing system software ² Also useful for small embedded system applications v Space and Time efficiency ² Understanding sources of program inefficiency ² Tuning program performance ² Writing compact code Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 16
Assembly Language Programming Tools v Editor ² Allows you to create and edit assembly language source files v Assembler ² Converts assembly language programs into object files ² Object files contain the machine instructions v Linker ² Combines object files created by the assembler with link libraries ² Produces a single executable program v Debugger ² Allows you to trace the execution of a program ² Allows you to view machine instructions, memory, and registers Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 17
Assemble and Link Process Source File Assembler Object File Linker Assembler Object File Link Libraries Source File Executable File A project may consist of multiple source files Assembler translates each source file separately into an object file Linker links all object files together with link libraries Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 18
MARS Assembler and Simulator Tool Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 19
Next. . . v Welcome to ICS 233 v High-Level, Assembly-, and Machine-Languages v Components of a Computer System v Chip Manufacturing Process v Technology Improvements v Programmer's View of a Computer System Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 20
Components of a Computer System Computer v Processor Memory ² Datapath I/O Devices ² Control v Memory & Storage Control ² Main Memory Processor ² Disk Storage Datapath Input B U S Output Disk v Input devices v Output devices Network v Bus: Interconnects processor to memory and I/O v Network: newly added component for Introduction communication ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 21
Input Devices Key Cap Spring Mechanical switch c d e f 8 9 a b 4 5 6 7 0 1 2 3 Logical arrangement of keys Introduction Conductor-coated membrane Contacts Membrane switch ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 22
Output Devices Cleaning of excess toner Charging Fusing of toner Rotating drum Heater Light from optical system Rollers Toner Sheet of paper Laser printing Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 23
Memory Devices v Volatile Memory Devices ² RAM = Random Access Memory ² DRAM = Dynamic RAM § 1 -Transistor cell + trench capacitor § Dense but slow, must be refreshed § Typical choice for main memory ² SRAM: Static RAM § 6 -Transistor cell, faster but less dense than DRAM § Typical choice for cache memory v Non-Volatile Memory Devices ² ROM = Read Only Memory ² Flash Memory Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 24
Magnetic Disk Storage A Magnetic disk consists of a collection of platters Provides a number of recording surfaces Read/write head Actuator Recording area Arm provides read/write heads for all surfaces The disk heads are connected together and move in conjunction Introduction Track 2 Track 1 Track 0 Arm Direction of rotation Platter Spindle ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 25
Memory Hierarchy v Registers are at the top of the hierarchy ² Typically few registers ² Fastest memory element Microprocessor v Level 1 Caches (8 – 64 KB) Registers v L 2 Cache (512 KB – 8 MB) ² Bigger but slower than L 1 Faster ² D-Cache stores data L 2 Cache Memory Bus Memory v Main Memory (1 – 2 GB) ² Access time: 50 – 70 ns Bigger L 1 I-Cache D-Cache ² I-Cache stores instructions I/O Bus Disk, Tape, etc v Disk Storage (> 200 GB) ² Much slower than main memory, Access time = 5 ms Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 26
Address, Data, and Control Bus v Address Bus ² Memory address is put on address bus ² If memory address = a bits then 2 a locations are addressed v Data Bus: bi-directional bus ² Data can be transferred in both directions on the data bus v Control Bus ² Signals control transfer of data ² Read request Processor address bus Address Register Introduction a bits data bus Data Register ² Write request ² Done transfer Memory d bits 0 1 2 3 read Bus Control . . . write done ICS 233 – Computer Architecture and Assembly Language – KFUPM 2 a – 1 © Muhamed Mudawar – slide 27
Processor v Datapath: part of a processor that executes instructions v Control: generates control signals for each instruction Instruction Cache Instruction Program Counter Next Program Counter Registers A L U Data Cache Control Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 28
Datapath Components v Program Counter (PC) ² Contains address of instruction to be fetched ² Next Program Counter: computes address of next instruction v Instruction and Data Caches ² Small and fast memory containing most recent instructions/data v Register File ² General-purpose registers used for intermediate computations v ALU = Arithmetic and Logic Unit ² Executes arithmetic and logic instructions v Buses ² Used to wire and interconnect the various components Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 29
Infinite Cycle implemented in Hardware Fetch - Execute Cycle Introduction Instruction Fetch Instruction Decode Execute Fetch instruction Compute address of next instruction Generate control signals for instruction Read operands from registers Compute result value Memory Access Read or write memory (load/store) Writeback Result Writeback result in a register ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 30
Next. . . v Welcome to ICS 233 v Assembly-, Machine-, and High-Level Languages v Components of a Computer System v Chip Manufacturing Process v Technology Improvements v Programmer's View of a Computer System Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 31
Chip Manufacturing Process Blank wafers Silicon ingot Slicer 8 -12 in diameter 12 -24 in long 20 to 30 processing steps < 0. 1 in thick Tested dies Die Tester Packaged dies Bond die to package Introduction Patterned wafer Individual dies Dicer Tested Packaged dies Part Tester ICS 233 – Computer Architecture and Assembly Language – KFUPM Ship to Customers © Muhamed Mudawar – slide 32
Wafer of Pentium 4 Processors v 8 inches (20 cm) in diameter v Die area is 250 mm 2 ² About 16 mm per side v 55 million transistors per die ² 0. 18 μm technology ² Size of smallest transistor ² Improved technology uses § 0. 13 μm and 0. 09 μm v Dies per wafer = 169 ² When yield = 100% ² Number is reduced after testing ² Rounded dies at boundary are useless Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 33
Effect of Die Size on Yield Good Die Defective Die Dramatic decrease in yield with larger dies Yield = (Number of Good Dies) / (Total Number of Dies) 1 Yield = (1 + (Defect per area Die area / 2))2 Die Cost = (Wafer Cost) / (Dies per Wafer Yield) Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 34
Inside the Pentium 4 Processor Chip Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 35
Next. . . v Welcome to ICS 233 v Assembly-, Machine-, and High-Level Languages v Components of a Computer System v Chip Manufacturing Process v Technology Improvements v Programmer's View of a Computer System Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 36
Technology Improvements v Vacuum tube → transistor → IC → VLSI v Processor ² Transistor count: about 30% to 40% per year v Memory ² DRAM capacity: about 60% per year (4 x every 3 yrs) ² Cost per bit: decreases about 25% per year v Disk ² Capacity: about 60% per year v Opportunities for new applications v Better organizations and designs Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 37
Growth of Capacity per DRAM Chip v DRAM capacity quadrupled almost every 3 years ² 60% increase per year, for 20 years Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 38
Workstation Performance Improvement is between 50% and 60% per year More than 1000 times improvement between 1987 and 2003 Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 39
Microprocessor Sales (1998 – 2002) v ARM processor sales exceeded Intel IA-32 processors, which came second v ARM processors are used mostly in cellular phones v Most processors today are embedded in cell phones, video games, digital TVs, PDAs, and a variety of consumer devices Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 40
Microprocessor Sales – cont'd Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 41
Next. . . v Welcome to ICS 233 v Assembly-, Machine-, and High-Level Languages v Components of a Computer System v Chip Manufacturing Process v Technology Improvements v Programmer's View of a Computer System Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 42
Programmer’s View of a Computer System Software Application Programs High-Level Language Level 5 Assembly Language Level 4 Operating System Interface SW & HW Level 3 Instruction Set Architecture Level 2 Microarchitecture Level 1 Level 0 Each level hides the details of the level below it ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 43 Hardware Physical Design Introduction Increased level of abstraction
Programmer's View – 2 v Application Programs (Level 5) ² Written in high-level programming languages ² Such as Java, C++, Pascal, Visual Basic. . . ² Programs compile into assembly language level (Level 4) v Assembly Language (Level 4) ² Instruction mnemonics are used ² Have one-to-one correspondence to machine language ² Calls functions written at the operating system level (Level 3) ² Programs are translated into machine language (Level 2) v Operating System (Level 3) ² Provides services to level 4 and 5 programs ² Translated to run at the machine instruction level (Level 2) Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 44
Programmer's View – 3 v Instruction Set Architecture (Level 2) ² Interface between software and hardware ² Specifies how a processor functions ² Machine instructions, registers, and memory are exposed ² Machine language is executed by Level 1 (microarchitecture) v Microarchitecture (Level 1) ² Controls the execution of machine instructions (Level 2) ² Implemented by digital logic v Physical Design (Level 0) ² Implements the microarchitecture ² Physical layout of circuits on a chip Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 45
Course Roadmap v Instruction set architecture (Chapter 2) v MIPS Assembly Language Programming (Chapter 2) v Computer arithmetic (Chapter 3) v Performance issues (Chapter 4) v Constructing a processor (Chapter 5) v Pipelining to improve performance (Chapter 6) v Memory and caches (Chapter 7) v Disk Storage (Chapter 8) Key to obtain a good grade: read the textbook! Introduction ICS 233 – Computer Architecture and Assembly Language – KFUPM © Muhamed Mudawar – slide 46
- Slides: 46