The x86 Architecture Lecture 15 Fri, Mar 4, 2005.

Slides:



Advertisements
Similar presentations
Registers of the 8086/ /2002 JNM.
Advertisements

Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
There are two types of addressing schemes:
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh.
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
Department of Computer Science and Software Engineering
Assembly 02. Outline mov Command Registers Memory EFLAGS Arithmetic 1.
Computer Organization And Assembly Language
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Practical Session 3. The Stack The stack is an area in memory that its purpose is to provide a space for temporary storage of addresses and data items.
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
Chapter 4 Basic Instructions. 4.1 Copying Data mov Instructions mov (“move”) instructions are really copy instructions, like simple assignment statements.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
The 8086 Microprocessor The 8086, announced in 1978, was the first 16-bit microprocessor introduced by Intel Corporation 8086 is 16-bit MPU. Externally.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
An Introduction to 8086 Microprocessor.
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Low Level Programming Lecturer: Duncan Smeed Overview of IA-32 Part 1.
Types of Registers (8086 Microprocessor Based)
Faculty of Engineering, Electrical Department,
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 ICS 51 Introductory Computer Organization Fall 2009.
The x86 Instruction Set Lecture 16 Mon, Mar 14, 2005.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Introduction to Assembly II Abed Asi Extended System Programming Laboratory (ESPL) CS BGU Fall 2013/2014.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
Compiler Construction Code Generation Activation Records
X86 Assembly Language We will be using the nasm assembler (other assemblers: MASM, as, gas)
6-4 CPU-Registers, effective address General registers vs Segment registers Computer Studies (AL)
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Intel 8086 MICROPROCESSOR ARCHITECTURE
BITS Pilani Pilani Campus Pawan Sharma Lecture / ES C263 INSTR/CS/EEE F241 Microprocessor Programming and Interfacing.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Stack Operations Dr. Hadi AL Saadi.
Computer Architecture and Assembly Language
Introduction to 8086 Microprocessor
Chapter 4 Data Movement Instructions
Basic Microprocessor Architecture
Assembly IA-32.
Homework Reading Continue work on mp1
BIC 10503: COMPUTER ARCHITECTURE
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
CS 301 Fall 2002 Computer Organization
MIPS Procedure Calls CSE 378 – Section 3.
Practical Session 4.
The Microprocessor & Its Architecture
Computer Architecture CST 250
X86 Assembly Review.
CSC 497/583 Advanced Topics in Computer Security
Computer Architecture and System Programming Laboratory
Presentation transcript:

The x86 Architecture Lecture 15 Fri, Mar 4, 2005

Overview See the reference “IA-32 Intel® Architecture Software Developer's Manual Volume 1: Basic Architecture” at ftp://download.intel.com/design/Pentium4/manual s/ pdf

Instructions Each instruction is of the form label: mnemonic operand 1, operand 2, operand 3 The label is optional. 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 reference “IA-32 Intel® Architecture Software Developer’s Manual Volume 2A: Instruction Set Reference, A- M” at ftp://download.intel.com/design/Pentium4/manual s/ pdf

Instructions See the instructions 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 Registers 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 Registers 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. Registers esi and edi are source and destination index registers for array and string operations.

The General-Purpose Registers 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 Registers string source eax ebx ecx edx ebp esi edi esp accumulator base pointer stack pointer string destination 031

The General-Purpose 16-Bit Registers bp si di sp dx cx bx ax 015 accumulator base pointer stack pointer string destination string source

The General-Purpose 8-Bit Registers ahal bhbl chcl dhdl accumulator

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, at most, 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 use eip or change its value.

Data Types 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 unless we have a specific need for one of the other types.

The Run-time Stack 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 to store where the top of the stack was 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 stack to its previous state. ebp  esp