IA32 (Pentium) Processor Architecture. Processor modes: 1.Protected (mode we will study) – 32-bit mode – 32-bit (4GB) address space 2.Virtual 8086 modes.

Slides:



Advertisements
Similar presentations
Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
Advertisements

Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 5 MIXING C AND ASSEMBLY.
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
Computer Organization and Assembly Languages Yung-Yu Chuang
Lecture 6 Machine Code: How the CPU is programmed.
Assembly 02. Outline mov Command Registers Memory EFLAGS Arithmetic 1.
IA-32 Processor Architecture
© 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.
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
Assembly Language Basic Concepts IA-32 Processor Architecture.
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.
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.
IA32 Addressing Modes Chapter 5 The ISA Level cont’d.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 2: IA-32 Processor Architecture (c) Pearson Education, All rights reserved. You.
6.828: PC hardware and x86 Frans Kaashoek
1 IA-32
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Today’s topics Parameter passing on the system stack Parameter passing on the system stack Register indirect and base-indexed addressing modes Register.
Intel Pentium II Processor Brent Perry Pat Reagan Brian Davis Umesh Vemuri.
Low Level Programming Lecturer: Duncan Smeed Overview of IA-32 Part 1.
Fall 2012 Chapter 2: x86 Processor Architecture. Irvine, Kip R. Assembly Language for x86 Processors 6/e, Chapter Overview General Concepts IA-32.
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
1 ICS 51 Introductory Computer Organization Fall 2009.
Sahar Mosleh California State University San MarcosPage 1 Stack operations, Applications and defining procedures.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
26-Nov-15 (1) CSC Computer Organization Lecture 6: Pentium IA-32.
In1211/04-PDS 1 TU-Delft IA-32. In1211/04-PDS 2 TU-Delft IA family l IA (Intel Architecture) is a family of processors (1985), (1989), -Pentium-line.
Other Processors. Having learnt MIPS, we can learn other major processors. Not going to be able to cover everything; will pick on the interesting aspects.
(-133)*33+44* *33+44*14 Input device memory calculator Output device controller Control bus data bus memory.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
Compiler Construction Code Generation Activation Records
1 The Stack and Procedures Chapter 5. 2 A Process in Virtual Memory  This is how a process is placed into its virtual addressable space  The code is.
Sahar Mosleh California State University San MarcosPage 1 Intel IA-32 Architecture This lecture describes the architecture of the Intel IA-32 processor.
X86 Assembly Language We will be using the nasm assembler (other assemblers: MASM, as, gas)
INTRODUCTION TO INTEL X-86 FAMILY
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
1 Assembly Language: Function Calls Jennifer Rexford.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Microprocessor, Programming & Interfacing Tutorial 2- Module 3.
BITS Pilani Pilani Campus Pawan Sharma Lecture / ES C263 INSTR/CS/EEE F241 Microprocessor Programming and Interfacing.
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.
Chapter Overview General Concepts IA-32 Processor Architecture
Stack Operations Dr. Hadi AL Saadi.
Assembly function call convention
Computer Architecture and Assembly Language
Assembly language.
C function call conventions and the stack
x86 Processor Architecture
Other Processors.
Computer skills CPU Jakub Yaghob.
Basic Microprocessor Architecture
Assembly IA-32.
Assembly Language for x86 Processors
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
CS 301 Fall 2002 Computer Organization
MIPS Procedure Calls CSE 378 – Section 3.
The Microprocessor & Its Architecture
Assembly Language (CSW 353)
Computer Architecture CST 250
X86 Assembly Review.
Other Processors Having learnt MIPS, we can learn other major processors. Not going to be able to cover everything; will pick on the interesting aspects.
CSC 497/583 Advanced Topics in Computer Security
Principles of Computers 18th Lecture
Computer Architecture and System Programming Laboratory
Presentation transcript:

IA32 (Pentium) Processor Architecture

Processor modes: 1.Protected (mode we will study) – 32-bit mode – 32-bit (4GB) address space 2.Virtual 8086 modes 3.Real mode – 1MB address space 4.System management mode

Registers 32-bit GPR’s (“general” purpose registers): eaxebp ebxesp ecxesi edxedi eflagseip

Registers e[a,b,c,d]x: 32 bits 16 bits 8 bits Note: eax is one register that can be viewed four different ways. (It is not four different registers. Schizophrenic?) 31 eax 0 15 ax 0 7 ah 0 7 al 0

Registers Not really GPR’s. – eax - accumulator; multiplication and division – ecx - loop counter – esp - stack pointers; don’t use – esi, edi - for memory-to-memory transfer – ebp - used by HLL for local vars on stack

Registers Additional registers: – 16-bit segment registers cs, es, ss, fs, ds, gs don’t use – eip instruction pointer / program counter (PC) don‘t use

Registers Additional registers: – eflags contains results of operations 32 individual bits – control flags – status flags: » C = carry (unsigned) » O = overflow (signed); also called V » S = sign; also called N for negative » Z = zero

Registers Additional registers: – floating point registers: ST(0) … ST(7) – MMX has 8 64-bit regs – XMM has bit regs

Fundamental instructions 1.mov- move 2.add- addition 3.sub- subtraction 4.call- call a function 5.ret- return from a function to caller

Fundamental instructions In all of the following examples, let: Kequ12  a constant (doesn’t use memory) adword52  a variable (uses memory)

MOV (MOVE) Fundamental instructions

mov - move – destination = source movdst, src

From IA-32 Intel Architecture Software Developer’s Manual, Volume 2A: Instruction Set Reference A-M

mov movr32, r/m32 Ex.movebx, ecx Ex.movebx, a movr/m32, r32 Ex.movecx, ebx Ex.mova, ebx movr32, imm32 Ex.movebx, K movr/m32, imm32 Ex.moveax, K Ex.mova, K

mov notes movr32, r/m32 Ex.movebx, ecx Ex.movebx, a movr/m32, r32 Ex.movecx, ebx Ex.mova, ebx movr32, imm32 Ex.movebx, K movr/m32, imm32 Ex.moveax, K Ex.mova, K Note the duplication: mov eax, ebx appear 2x mov eax, K appears 2x. Note: No mov m32, m32. Note: No imm32, imm32. Why not? Flags affected: None. – Will mov eax, 0 affect the Z flag?

Problem: swap Swap the contents of memory location A with the contents of memory location B (and vice versa). – Assume that A and B are dwords that are already defined for you.

ADD Fundamental instructions

add – addition – Two add instructions (add and add w/ carry): adddst, src dst = dst + src adcdst, src dst = dst + src + CF We will only use add.

From IA-32 Intel Architecture Software Developer’s Manual, Volume 2A: Instruction Set Reference A-M (advanced)

add addeax, imm32 Ex.addeax, K addr/m32, imm32 Ex.addebx, K Ex.adda, K addr/m32, r32 Ex.addebx, ecx Ex.adda, ecx addr32, r/m32 Ex.addebx, ecx Ex.addebx, a

add notes addeax, imm32 Ex.addeax, K addr/m32, imm32 Ex.addebx, K Ex.adda, K addr/m32, r32 Ex.addebx, ecx Ex.adda, ecx addr32, r/m32 Ex.addebx, ecx Ex.addebx, a Remember: eax is the accumulator. Note the duplication. Note: No add m32, m32. Flags affected: O, S, Z, C Would you call this a load/store architecture?

Problem: add ‘em up You are given 3 dwords, A, B, and C that have been previously assigned values. Add them up and save the result in a dword called SUM.

SUB Fundamental instructions

sub – subtraction – Like add, there are two subtract instructions, sub, and subtract w/ borrow: subdst, src dst = dst - src sbbdst, src dst = dst – (src + CF) We will only use sub.

From IA-32 Intel Architecture Software Developer’s Manual, Volume 2B: Instruction Set Reference N-Z (advanced)

sub subeax, imm32 Ex.subeax, K subr/m32, imm32 Ex.subebx, K Ex.suba, K subr/m32, r32 Ex.subebx, ecx Ex.suba, ecx subr32, r/m32 Ex.subebx, ecx Ex.subebx, a

sub notes subeax, imm32 Ex.subeax, K subr/m32, imm32 Ex.subebx, K Ex.suba, K subr/m32, r32 Ex.subebx, ecx Ex.suba, ecx subr32, r/m32 Ex.subebx, ecx Ex.subebx, a Remember: eax is the accumulator. Note the duplication. Note: No sub m32, m32. Flags affected: O, S, Z, C Would you call this a load/store architecture?

Problem: subtract ‘em You are given 3 dwords, A, B, and C that have been previously assigned values. Subtract one from the first, two from the second, and ten from the third. Would your solution still work if this were a load/store architecture?

CALL Fundamental instructions

call - call a function (AKA subroutine, routine, procedure) – Use registers or stack to pass arguments to function. – Use registers to return value from function. – Ex. moveax, 0;input param to function f is 0 in eax callf;call our function movebx, eax;save value returned for future use

Fundamental instructions Windows calling conventions: 1.Always assume that all flags are affected bit Windows calling conventions: a)EBX, ESI, and EDI are always preserved by called function. b)EAX, ECX, and EDX can be freely modified (by called function).

From IA-32 Intel Architecture Software Developer’s Manual, Volume 2A: Instruction Set Reference A-M

Call example The dump function can be called at any time by your program to display the contents of registers (including the EFLAGS register). Unlike other Windows functions, it preserves all of the caller’s registers.

Call example ; align4.code;insert executable instructions below mainPROC;program execution begins here moveax, 1;set regs values movebx, 2 movecx, 3 movedx, 4 movesi, 5 movedi, 6 calldump;show contents of regs moveax, input(prompt);prompt the user exit;end of program mainENDP

; align4.code;insert executable instructions below mainPROC;program execution begins here moveax, 1;set regs values movebx, 2 movecx, 3 movedx, 4 movesi, 5 movedi, 6 calldump;show contents of regs moveax, input(prompt);prompt the user exit;end of program mainENDP Call example

ret Return from procedure (AKA function, method, routine, or subroutine). Flags affected: none.

Problems: One way to pass (and return) arguments to functions is to use registers. 1.Write a function that doubles a number. The number to be doubled is in eax. The result should also be in eax. 2.Write a function that adds three numbers together.