CMSC Lecture 03. UMBC, CMSC313, Richard Chang

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

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

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

The x86 Architecture

Assembler Programming. Lecture 2

Hardware and Software Architecture. Chapter 2

Complex Instruction Set Computer (CISC)

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

Addressing Modes on the x86

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

System calls and assembler

Instruction Set Architectures

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

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,...

Instruction Set Architectures

The Microprocessor and its Architecture

Reverse Engineering II: The Basics

Credits and Disclaimers

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

Advanced Microprocessors

Instruction Set Architectures

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

Lab 2: Introduction to Assembly Language Programming

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

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

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

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

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

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

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

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

x86 Assembly Tutorial COS 318: Fall 2017

Basic Execution Environment

The Instruction Set. Chapter 5

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

Chapter 3: Addressing Modes

Credits and Disclaimers

The von Neumann Machine

Computer System Architecture

The Pentium Processor

Module 3 Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA) Data Types

CS241 Computer Organization Spring Introduction to Assembly

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

Code segment Stack segment

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

EEM336 Microprocessors I. Addressing Modes

Reverse Engineering II: The Basics

The von Neumann Machine

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

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

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

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

IA32 Intel 32-bit Architecture

T Reverse Engineering Malware: Static Analysis I

EEM336 Microprocessors I. The Microprocessor and Its Architecture

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

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

IA32/Linux Virtual Memory Architecture

Chapter 11. Addressing Modes

Assembly Language. Lecture 2 x86 Processor Architecture

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

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

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

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

Memory Models. Registers

Introduction to Machine/Assembler Language

Chapter 2: The Microprocessor and its Architecture

MACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION

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

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

MICROPROCESSOR TECHNOLOGY

Real instruction set architectures. Part 2: a representative sample

Lecture 2 Assembly Language

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

CHAPTER 3 BASIC EXECUTION ENVIRONMENT

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

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

EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim

The System Bus Model

CMSC 313 Lecture 08 Project 2 Questions Recap Indexed Addressing Examples Some i386 string instructions A Bigger Example: Escape Sequence Project

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

UMBC. contain new IP while 4th and 5th bytes contain CS. CALL BX and CALL [BX] versions also exist. contain displacement added to IP.

Assembly Language Lab # 9

Binghamton University. CS-220 Spring x86 Assembler. Computer Systems: Sections

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

Computer Architecture and Assembly Language. Practical Session 3

CS241 Computer Organization Spring 2015 IA

UNIT 2 PROCESSORS ORGANIZATION CONT.

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

x86 assembly CS449 Spring 2016

Lecture 3: Instruction Set Architecture

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

CS165 Computer Security. Understanding low-level program execution Oct 1 st, 2015

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

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

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

Transcription:

CMSC Lecture 03 Moore s Law Evolution of the Pentium Chip IA-32 Basic Execution Environment IA-32 General Purpose Registers Hello World in Linux Assembly Language Addressing Modes UMBC, CMSC313, Richard Chang <chang@umbcedu>

Moore s Law In the mid-1960 s, Intel Chairman of the Board Gordon Moore observed that the number of transistors that would be incorporated on a silicon die would double every 18 months for the next several years His prediction has continued to hold true Perhaps a self-fulfilling prophecy? UMBC, CMSC313, Richard Chang <chang@umbcedu>

Table 2-1 Key Features of contemporary IA-32 processors Intel Processor Date Introduced Microarchitecture Clock Frequency at Introduction Transistors per Die Register Sizes 1 System Bus Bandwi dth Max Extern Addr Space On-die Caches 2 Pentium III processor 3 1999 P6 700 MHz 28 M GP: 32 FPU: 80 MMX: 64 XMM: 128 Up to 106 GB/s 64 GB 32KB L1; 256KB L2 Pentium 4 processor 2000 Intel NetBurst microarchitecture 150 GHz 42 M GP: 32 FPU: 80 MMX: 64 XMM: 128 32 GB/s 64 GB 12K µop Execution Trace Cache; 8KB L1; 256KB L2 NOTES: 1 The register size and external data bus size are given in bits 2 First level cache is denoted using the abbreviation L1, 2nd level cache is denoted as L2 3 Intel Pentium III and Pentium III Xeon processors, with advanced transfer cache and built on 018 micron process technology, were introduced in October 1999

Table 2-2 Key Features of previous generations of IA-32 Processor Intel Processor Date Introduced Max Clock Frequency at Introduction Transis -tors per Die Register Sizes 1 Ext Data Bus Size 2 Max Extern Addr Space Caches 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 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: 8KB 64 4 GB L1:16KB 64 64 GB L1: 16KB L2: 256KB or 512KB 64 64 GB L1: 32KB L2: 256KB or 512KB 64 64 GB L1: 32KB L2: 512KB NOTES: 1 The register size and external data bus size are given in bits Note also that each 32-bit general-purpose (GP) registers can be addressed as an 8- or a 16-bit data registers in all of the processors 2 Internal data paths that are 2 to 4 times wider than the external data bus for each processor

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 3-3

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>

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 EIP MOV 08A94068 1734 Code EDX EBP ESI EDI ESP Data x Register Indirect 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

toupperasm Prompt for user input Use Linux system call to get user input Scan each character of user input and convert all lower case characters to upper case How to: work with 8-bit data specify ASCII constant compare values loop control UMBC, CMSC313, Richard Chang <chang@umbcedu>

Debugging Assembly Language Programs Cannot just put print statements everywhere Use gdb to: examine contents of registers exmaine contents of memory set breakpoints single-step through program READ THE GDB SUMMARY ONLINE! UMBC, CMSC313, Richard Chang <chang@umbcedu>

gdb ommand Summary Command Example Description run quit cont start program quit out of gdb continue execution after a break break [addr] break *_start+5 sets a breakpoint delete [n] delete 4 removes nth breakpoint delete info break stepi removes all breakpoints lists all breakpoints execute next instruction stepi [n] stepi 4 execute next n instructions nexti execute next instruction, stepping over function calls nexti [n] nexti 4 execute next n instructions, stepping over function calls where show where execution halted disas [addr] disas _start disassemble instructions at given address info registers dump contents of all registers print/d [expr] print/d $ecx print expression in decimal print/x [expr] print/x $ecx print expression in hex print/t [expr] print/t $ecx print expression in binary x/nfu [addr] x/12xw &msg Examine contents of memory in given format display [expr] display $eax automatically print the expression each time the program is halted display/i $eip print machine instruction each time the program is halted info display show list of automatically displays undisplay [n] undisplay 1 remove an automatic display

Next Time Overview of i386 instruction set Arithmetic instructions, logical instructions EFLAGS register UMBC, CMSC313, Richard Chang <chang@umbcedu>