CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 03, SPRING 2013

Similar documents
CMSC Lecture 03. UMBC, CMSC313, Richard Chang

Introduction to IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung

Lecture 15 Intel Manual, Vol. 1, Chapter 3. Fri, Mar 6, Hampden-Sydney College. The x86 Architecture. Robb T. Koether. Overview of the x86

Instruction Set Architectures

The x86 Architecture

Assembler Programming. Lecture 2

Addressing Modes on the x86

Hardware and Software Architecture. Chapter 2

Instruction Set Architectures

CS 16: Assembly Language Programming for the IBM PC and Compatibles

UMBC. A register, an immediate or a memory address holding the values on. Stores a symbolic name for the memory location that it represents.

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Complex Instruction Set Computer (CISC)

Instruction Set Architectures

Assembly Language Each statement in an assembly language program consists of four parts or fields.

MODE (mod) FIELD CODES. mod MEMORY MODE: 8-BIT DISPLACEMENT MEMORY MODE: 16- OR 32- BIT DISPLACEMENT REGISTER MODE

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture Included elements of the IA-64 bit

IA-32 Architecture COE 205. Computer Organization and Assembly Language. Computer Engineering Department

The von Neumann Machine

CS241 Computer Organization Spring Introduction to Assembly

System calls and assembler

Datapoint 2200 IA-32. main memory. components. implemented by Intel in the Nicholas FitzRoy-Dale

The Microprocessor and its Architecture

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Computer System Architecture

The von Neumann Machine

Assembly I: Basic Operations. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Reverse Engineering II: The Basics

Advanced Microprocessors

Lab 2: Introduction to Assembly Language Programming

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

Registers. Ray Seyfarth. September 8, Bit Intel Assembly Language c 2011 Ray Seyfarth

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

Credits and Disclaimers

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher

Assembly Language. Lecture 2 x86 Processor Architecture

The Instruction Set. Chapter 5

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

Module 3 Instruction Set Architecture (ISA)

The x86 Architecture. ICS312 - Spring 2018 Machine-Level and Systems Programming. Henri Casanova

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-11: 80x86 Architecture

Machine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Basic Execution Environment

Moodle WILLINGDON COLLEGE SANGLI (B. SC.-II) Digital Electronics

Memory Models. Registers

MICROPROCESSOR TECHNOLOGY

The Pentium Processor

Code segment Stack segment

Low Level Programming Lecture 2. International Faculty of Engineerig, Technical University of Łódź

Instruction Set Architecture (ISA) Data Types

EEM336 Microprocessors I. The Microprocessor and Its Architecture

Chapter 3: Addressing Modes

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

Credits and Disclaimers

Introduction to Machine/Assembler Language

IA32 Intel 32-bit Architecture

Scott M. Lewandowski CS295-2: Advanced Topics in Debugging September 21, 1998

x86 Assembly Tutorial COS 318: Fall 2017

IA-32 Architecture. Computer Organization and Assembly Languages Yung-Yu Chuang 2005/10/6. with slides by Kip Irvine and Keith Van Rhein

COS 318: Operating Systems. Overview. Prof. Margaret Martonosi Computer Science Department Princeton University

Lecture (02) The Microprocessor and Its Architecture By: Dr. Ahmed ElShafee

MACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION

Chapter 11. Addressing Modes

Assembly Language for x86 Processors 7 th Edition. Chapter 2: x86 Processor Architecture

6/17/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

Real instruction set architectures. Part 2: a representative sample

EEM336 Microprocessors I. Addressing Modes

IA32/Linux Virtual Memory Architecture

Chapter 2: The Microprocessor and its Architecture

CS241 Computer Organization Spring 2015 IA

Reverse Engineering II: The Basics

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 2: IA-32 Processor Architecture. Chapter Overview.

CHAPTER 3 BASIC EXECUTION ENVIRONMENT

eaymanelshenawy.wordpress.com

Dr. Ramesh K. Karne Department of Computer and Information Sciences, Towson University, Towson, MD /12/2014 Slide 1

For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

Computer Organization (II) IA-32 Processor Architecture. Pu-Jen Cheng

Microprocessor (COM 9323)

T Reverse Engineering Malware: Static Analysis I

Access. Young W. Lim Fri. Young W. Lim Access Fri 1 / 18

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016

INTEL Architectures GOPALAKRISHNAN IYER FALL 2009 ELEC : Computer Architecture and Design

Today: Machine Programming I: Basics

x86 assembly CS449 Spring 2016

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 7. Procedures and the Stack

Lecture 3: Instruction Set Architecture

Access. Young W. Lim Sat. Young W. Lim Access Sat 1 / 19

Assembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012

MACHINE-LEVEL PROGRAMMING I: BASICS

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

Today: Machine Programming I: Basics. Machine Level Programming I: Basics. Intel x86 Processors. Intel x86 Evolution: Milestones

Program Exploitation Intro

Assembly Language Programming Introduction

CSC 8400: Computer Systems. Machine-Level Representation of Programs

Transcription:

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 03, SPRING 2013

TOPICS TODAY Moore s Law Evolution of Intel CPUs IA-32 Basic Execution Environment IA-32 General Purpose Registers Hello World in Linux Assembly Language Addressing modes

INTEL CPUS

15 Historical Development Moore s Law (1965) Gordon Moore, Intel founder The density of transistors in an integrated circuit will double every year Contemporary version: The density of silicon chips doubles every 18 months But this law cannot hold forever 35

Rock s Law 15 Historical Development Arthur Rock, Intel financier The cost of capital equipment to build semiconductors will double every four years In 1968, a new chip plant cost about $12,000 At the time, $12,000 would buy a nice home in the suburbs An executive earning $12,000 per year was making a very comfortable living 36

15 Historical Development Rock s Law In 2010, a chip plants under construction cost well over $4 billion $4 billion is more than the gross domestic product of some small countries, including Barbados, Mauritania, and Rwanda For Moore s Law to hold, Rock s Law must fall, or vice versa But no one can say which will give out first 37

INTEL 64 AND IA-32 ARCHITECTURES Intel Processor Table 2-3 Key Features of Previous Generations of IA-32 Processors Max Clock Frequency/ Technology at Introduction Date Introduced Transistors Register Sizes 1 Ext Data Bus Size 2 Max Extern Addr Space 8086 1978 8 MHz 29 K 16 GP 16 1 MB None Intel 286 1982 125 MHz 134 K 16 GP 16 16 MB Note 3 Intel386 DX Processor 1985 20 MHz 275 K 32 GP 32 4 GB Note 3 Caches Intel486 DX Processor 1989 25 MHz 12 M 32 GP 80 FPU Pentium Processor 1993 60 MHz 31 M 32 GP 80 FPU Pentium Pro Processor 1995 200 MHz 55 M 32 GP 80 FPU Pentium II Processor 1997 266 MHz 7 M 32 GP 80 FPU 64 MMX Pentium III Processor 1999 500 MHz 82 M 32 GP 80 FPU 64 MMX 128 XMM 32 4 GB L1: 8 KB 64 4 GB L1:16 KB 64 64 GB L1: 16 KB L2: 256 KB or 512 KB 64 64 GB L1: 32 KB L2: 256 KB or 512 KB 64 64 GB L1: 32 KB L2: 512 KB Pentium III and Pentium III Xeon Processors 1999 700 MHz 28 M 32 GP 80 FPU 64 MMX 128 XMM 64 64 GB L1: 32 KB L2: 256 KB Pentium 4 Processor 2000 150 GHz, Intel NetBurst Microarchitecture Intel Xeon Processor 2001 170 GHz, Intel NetBurst Microarchitecture Intel Xeon Processor 2002 220 GHz, Intel NetBurst Microarchitecture, HyperThreading Technology Pentium M Processor 2003 160 GHz, Intel NetBurst Microarchitecture 42 M 32 GP 80 FPU 64 MMX 128 XMM 42 M 32 GP 80 FPU 64 MMX 128 XMM 55 M 32 GP 80 FPU 64 MMX 128 XMM 77 M 32 GP 80 FPU 64 MMX 128 XMM 64 64 GB 12K µop Execution Trace Cache; L1: 8KB L2: 256 KB 64 64 GB 12K µop Execution Trace Cache; L1: 8KB L2: 512KB 64 64 GB 12K µop Execution Trace Cache; L1: 8KB L2: 512KB 64 4 GB L1: 64KB L2: 1 MB Intel Pentium 4 Processor Supporting Hyper-Threading Technology at 90 nm process 2004 340 GHz, Intel NetBurst Microarchitecture, HyperThreading Technology 125 M 32 GP 80 FPU 64 MMX 128 XMM 64 64 GB 12K µop Execution Trace Cache; L1: 16KB L2: 1 MB NOTE: 1 The register size and external data bus size are given in bits Note also that each 32-bit generalpurpose (GP) registers can be addressed as an 8- or a 16-bit data registers in all of the processors 2 Internal data paths are 2 to 4 times wider than the external data bus for each processor

Intel Processor Table 2-1 Key Features of Most Recent IA-32 Processors Date Introduced Microarchitecture Top-Bin Clock Frequency at Introduction Transistors Register Sizes 1 Syste m Bus Bandwidth Max Extern Addr Space On-Die Caches 2 Intel Pentium M 2004 Intel Pentium M Processor 755 3 Processor 200 GHz 140 M GP: 32 FPU: 80 MMX: 64 XMM: 128 32 GB/s 4 GB L1: 64 KB L2: 2 MB Intel Core Duo Processor T2600 3 2006 Improved Intel Pentium M Processor Microarchitecture; Dual Core; Intel Smart Cache, Advanced Thermal Manager 216 GHz 152M GP: 32 FPU: 80 MMX: 64 XMM: 128 53 GB/s 4 GB L1: 64 KB L2: 2 MB (2MB Total) Intel Atom Processor Z5xx series 2008 Intel Atom Microarchitecture; Intel Virtualization Technology 186 GHz - 800 MHz 47M GP: 32 FPU: 80 MMX: 64 XMM: 128 Up to 42 GB/s 4 GB L1: 56 KB 4 L2: 512KB

Intel Processor Table 2-2 Key Features of Most Recent Intel 64 Processors (Contd) Date Introduced Microarchitec-ture Top-Bin Frequency at Introduction Transistor s Register Sizes System Bus/QP I Link Speed Max Extern Addr Space On-Die Caches Intel Core i7-620m Processor 2010 Intel Turbo Boost Technology, Intel microarchitecture code name Westmere; Dualcore; HyperThreading Technology; Intel 64 Architecture; Intel Virtualization Technology, Integrated graphics 266 GHz 383 M GP: 32, 64 FPU: 80 MMX: 64 XMM: 128 64 GB L1: 64 KB L2: 256KB L3: 4MB Intel Xeon- Processor 5680 2010 Intel Turbo Boost Technology, Intel microarchitecture code name Westmere; Six core; HyperThreading Technology; Intel 64 Architecture; Intel Virtualization Technology 333 GHz 11B GP: 32, 64 FPU: 80 MMX: 64 XMM: 128 QPI: 64 GT/s; 32 GB/s 1 TB L1: 64 KB L2: 256KB L3: 12MB Intel Xeon- Processor 7560 2010 Intel Turbo Boost Technology, Intel microarchitecture code name Nehalem; Eight core; HyperThreading Technology; Intel 64 Architecture; Intel Virtualization Technology 226 GHz 23B GP: 32, 64 FPU: 80 MMX: 64 XMM: 128 QPI: 64 GT/s; Memory: 76 GB/s 16 TB L1: 64 KB L2: 256KB L3: 24MB Intel Core i7-2600k Processor 2011 Intel Turbo Boost Technology, Intel microarchitecture code name Sandy Bridge; Four core; HyperThreading Technology; Intel 64 Architecture; Intel Virtualization Technology, Processor graphics, Quicksync Video 340 GHz 995M GP: 32, 64 FPU: 80 MMX: 64 XMM: 128 YMM: 256 DMI: 5 GT/s; Memory: 21 GB/s 64 GB L1: 64 KB L2: 256KB L3: 8MB Intel Xeon- Processor E3-1280 2011 Intel Turbo Boost Technology, Intel microarchitecture code name Sandy Bridge; Four core; HyperThreading Technology; Intel 64 Architecture; Intel Virtualization Technology 350 GHz GP: 32, 64 FPU: 80 MMX: 64 XMM: 128 YMM: 256 DMI: 5 GT/s; Memory: 21 GB/s 1 TB L1: 64 KB L2: 256KB L3: 8MB Intel Xeon- Processor E7-8870 2011 Intel Turbo Boost Technology, Intel microarchitecture code name Westmere; Ten core; HyperThreading Technology; Intel 64 Architecture; Intel Virtualization Technology 240 GHz 22B GP: 32, 64 FPU: 80 MMX: 64 XMM: 128 QPI: 64 GT/s; Memory: 102 GB/s 16 TB L1: 64 KB L2: 256KB L3: 30MB

17 The von Neumann Model This is a general depiction of a von Neumann system: These computers employ a fetchdecode-execute cycle to run programs as follows 48

BASIC EXECUTION ENVIRONMENT Basic Program Execution Registers Eight 32-bit General-Purpose Registers Registers 2 32-1 Address Space* Six 16-bit Registers Segment Registers 32-bits 32-bits EFLAGS Register EIP (Instruction Pointer Register) FPU Registers Eight 80-bit Registers Floating-Point Data Registers 0 16-bits 16-bits 16-bits 48-bits 48-bits Control Register Status Register Tag Register Opcode Register (11-bits) FPU Instruction Pointer Register FPU Data (Operand) Pointer Register *The address space can be flat or segmented Using the physical address extension mechanism, a physical address space of 2 36-1 can be addressed MMX Registers Eight 64-bit Registers MMX Registers SSE and SSE2 Registers Eight 128-bit Registers XMM Registers 32-bits MXCSR Register Figure 3-1 IA-32 Basic Execution Environment

General-Purpose Registers 31 16 15 8 7 AH AL BH BL CH CL DH DL BP SI DI SP 0 16-bit AX BX CX DX 32-bit EAX EBX ECX EDX EBP ESI EDI ESP Figure 3-4 Alternate General-Purpose Register Names

EAX Accumulator for operands and results data EBX Pointer to data in the DS segment ECX Counter for string and loop operations EDX I/O pointer ESI Pointer to data in the segment pointed to by the DS register; source pointer for string operations9 EDI Pointer to data (or destination) in the segment pointed to by the ES register; destination pointer for string operations ESP Stack pointer (in the SS segment) EBP Pointer to data on the stack (in the SS segment)

Hello World in Linux Assembly Use your favorite UNIX editor (vi, emacs, pico, ) Assemble using NASM on glumbcedu nasm -f elf helloasm NASM documentation is on-line Need to load the object file ld helloo Execute aout CMSC 121 Introduction to UNIX UMBC, CMSC313, Richard Chang <chang@umbcedu>

ADDRESSING MODES

80x86 Addressing Modes We want to store the value 1734h The value 1734h may be located in a register or in memory The location in memory might be specified by the code, by a register, Assembly language syntax for MOV MOV DEST, SOURCE

Addressing Modes EAX EIP MOV Code EBX ECX 1734 EDX EBP ESI EDI ESP Data Register from Register MOV EAX, ECX

Addressing Modes EAX EIP MOV Code EBX ECX 08A94068 EDX EBP ESI EDI ESP 1734 Data Register from Register Indirect MOV EAX, [ECX]

Addressing Modes EAX EBX EIP MOV 08A94068 Code ECX EDX EBP ESI EDI ESP Data x 1734 Register from Memory MOV EAX, [08A94068] MOV EAX, [x]

Addressing Modes EAX EBX EIP MOV 1734 Code ECX EDX EBP ESI EDI ESP Data Register from Immediate MOV EAX, 1734

Addressing Modes EAX 08A94068 EBX EIP MOV 1734 Code ECX EDX EBP ESI EDI ESP Data Register Indirect from Immediate MOV [EAX], DWORD 1734

Addressing Modes! EAX! EBX! ECX! EDX! EBP! ESI! EDI! ESP! EIP! MOV! 08A94068! 1734!!!! Code! Data! x! Memory from Immediate! MOV![08A94068], DWORD 1734! MOV [x], DWORD 1734!

Notes on Addressing Modes More complicated addressing modes later: MOV EAX, [ESI+4*ECX+12] Figures not drawn to scale Constants 1734h and 08A94068h take 4 bytes (little endian) Some addressing modes are not supported by some operations Labels represent addresses not contents of memory

NEXT TIME toupperasm! the gdb debugger Overview of i386 Instruction Set Arithmetic Instructions EFLAGS Register