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

Similar documents
The x86 Architecture

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

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

Introduction to IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung

Code segment Stack segment

Complex Instruction Set Computer (CISC)

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

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

Assembler Programming. Lecture 2

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

Module 3 Instruction Set Architecture (ISA)

Assembly Language Lab # 9

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

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

Basic Execution Environment

Hardware and Software Architecture. Chapter 2

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

Addressing Modes on the x86

The Microprocessor and its Architecture

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

Credits and Disclaimers

CS241 Computer Organization Spring 2015 IA

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

Lab 2: Introduction to Assembly Language Programming

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

x86 Assembly Tutorial COS 318: Fall 2017

Reverse Engineering II: The Basics

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

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

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

Instruction Set Architectures

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

The x86 Instruction Set

Chapter 3: Addressing Modes

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

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

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

Credits and Disclaimers

Instruction Set Architecture (ISA) Data Types

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

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

IA32 Intel 32-bit Architecture

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

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

CMSC Lecture 03. UMBC, CMSC313, Richard Chang

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

Chapter 2: The Microprocessor and its Architecture

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

CSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature

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

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

EEM336 Microprocessors I. Addressing Modes

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

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

Lecture 5:8086 Outline: 1. introduction 2. execution unit 3. bus interface unit

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

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

The Instruction Set. Chapter 5

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

CHAPTER 3 BASIC EXECUTION ENVIRONMENT

icroprocessor istory of Microprocessor ntel 8086:

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

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

Reverse Engineering II: The Basics

8086 INTERNAL ARCHITECTURE

Intel 8086 MICROPROCESSOR ARCHITECTURE

Assembly Language: IA-32 Instructions

Computer Architecture and Assembly Language. Practical Session 3

iapx Systems Electronic Computers M

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

Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 2 Assembly Language Fundamentals

UNIT 2 PROCESSORS ORGANIZATION CONT.

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

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

Practical Malware Analysis

Instruction Set Architectures

SYSC3601 Microprocessor Systems. Unit 2: The Intel 8086 Architecture and Programming Model

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Inline Assembler. Willi-Hans Steeb and Yorick Hardy. International School for Scientific Computing

CSCE 212H, Spring 2008 Lab Assignment 3: Assembly Language Assigned: Feb. 7, Due: Feb. 14, 11:59PM

mith College Computer Science CSC231 - Assembly Week #4 Dominique Thiébaut

Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p

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

EEM336 Microprocessors I. The Microprocessor and Its Architecture

LAB 5 Arithmetic Operations Simple Calculator

Lecture 5: Computer Organization Instruction Execution. Computer Organization Block Diagram. Components. General Purpose Registers.

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

Program Exploitation Intro

System calls and assembler

An Introduction to x86 ASM

Lecture 3: Instruction Set Architecture

CS241 Computer Organization Spring Introduction to Assembly

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

The von Neumann Machine

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 4 Solution

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

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

Transcription:

Lecture 15 Intel Manual, Vol. 1, Chapter 3 Hampden-Sydney College Fri, Mar 6, 2009

Outline 1 2

Overview See the reference IA-32 Intel Software Developer s Manual Volume 1: Basic, Chapter 3.

Instructions Each instruction is of the form [label:] mnemonic [operand 1 ][, operand 2 ][, operand 3 ] The number of operands is 0, 1, 2, or 3, depending on the mnemonic. Each operand is either An immediate value, A register, or A memory address.

Source and Destination Operands Each operand is either a source operand or an destination operand. A source operand, in general, may be An immediate value, A register, or A memory address. A destination operand, in general, may be A register, or A memory address.

Source and Destination Operands The standard interpretation of mnemonic operand 1,operand 2 is that operand 1 is the destination and operand 2 is the source. operand 1 operand 1 op operand 2 The Intel manuals are written according to the standard interpretation.

Source and Destination Operands However, the gnu interpretation of mnemonic operand 1,operand 2 is that operand 1 is the source and operand 2 is the destination. operand 1 op operand 2 operand 2 Therefore, we will have to interpret the information in the Intel manuals accordingly.

Instructions Not every logical combination of operands is permitted in every instruction. See the references IA-32 Intel Software Developer s Manual Volume 2A: Instruction Set Reference, A-M IA-32 Intel Software Developer s Manual Volume 2B: Instruction Set Reference, N-Z

Instructions Different instructions require different numbers of operands. For example, hlt - 0 operands inc - 1 operand add - 2 operands imul - 1, 2, or 3 operands

Address Space The memory addresses are 32 bits, so they can access up to 4 GB of memory. A global variable or function is referenced by its name, which is a label representing its address. Local variables are referenced by an offset from the base pointer, which holds the base address of the activation record on the stack.

Basic There are Eight 32-bit general-purpose registers, One 32-bit EFLAGS register, One 32-bit instruction pointer register (eip), and Other special-purpose registers.

The General-Purpose The eight 32-bit general-purpose registers are eax, ebx, ecx, edx, esi, edi, ebp, and esp. For calculations, we will use eax, ebx, ecx, and edx. Register esp is the stack pointer. Register ebp is the base pointer. esi and edi are source and destination index registers for array and string operations.

The General-Purpose The registers eax, ebx, ecx, and edx may be accessed as 32-bit, 16-bit, or 8-bit registers. The other four registers can be accessed as 32-bit or 16-bit. For example, Register eax represents a 32-bit quantity. The low-order two bytes of eax may be accessed through the name ax. The high-order byte of ax is named ah. The low-order byte of ax is named al.

The General-Purpose 32-Bit 31 0 eax ebx ecx edx ebp esi edi esp Accumulator Base pointer Array source Array destination Stack pointer

The General-Purpose 16-Bit 31 16 15 0 ax bx cx dx bp si di sp Accumulator Base pointer Array source Array destination Stack pointer

The General-Purpose 8-Bit 31 16 15 8 7 0 ah al bh bl ch cl dh dl bp si di sp Accumulator Base pointer Array source Array destination Stack pointer

EFLAGS Register The various bits of the 32-bit EFLAGS register are set (1) or reset (0) according to the results of certain operations. We will be interested in the bits CF - carry flag PF - parity flag ZF - zero flag SF - sign flag

Instruction Pointer Finally, there is the eip register, which is the instruction pointer. Register eip holds the address of the next instruction to be executed. We should never change the value of eip directly. It will be updated automatically as necessary.

There are 5 integer data types. Byte - 8 bits. Word - 16 bits. Doubleword - 32 bits. Quadword - 64 bits. Double quadword - 128 bits. We will use doublewords (for ints) unless we have a specific need for one of the other types.

The run-time stack supports procedure calls and the passing of parameters between procedures. The stack is located in memory. The stack grows towards low memory. When we push a value, esp is decremented. When we pop a value, esp is incremented.

Using the Run-time Stack Typically, if an operation produces a result, we will push that result onto the stack. The next operation, if it expects a previous result, will pop it off the stack. The alternative is to use the registers to pass results, but that is much more complicated since we would have to keep track of which registers were free.

Function Calls and the Base Pointer When we make a function call, we use the base pointer ebp to store the location of the top of the stack esp before the function call. esp ebp Then we push the parameters and local variables of the function onto the stack. When we return from the function, we use the base pointer to restore the top of the stack to its previous location. ebp esp

Homework Download the Intel Manual, Vol. 1, and read Chapter 3.