09-x86

09-x86 - 1 Introduction to x86 Part 1 CS216: Program and...

Info iconThis preview shows pages 1–20. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Introduction to x86 Part 1 CS216: Program and Data Representation University of Virginia Computer Science Spring 2009 Aaron Bloomfield 2 CS216 Roadmap Data Representation Program Representation Bits 01001010 Addresses, Numbers, Characters 0x42381a, 3.14, ‘x’ Objects “Hello” Arrays [‘H’,’i’,\0] Python code High-level language C++ code Low-level language Virtual Machine language JVML Assembly x86 Real World Problems Real World Physics Machine Introduction to x86 4 History of x86 • 1971 – 4004, 4-bit words • 1972 – 8008, 8-bit words • 1978 – 8086, 16-bit words • 1982 – 80286 • 1985 – 80386, 32-bit words • 1989 – 80486 • 1993 – Pentium • 1995 – Pentium Pro • 1997 – Pentium II • 1998 – Pentium III • 2000 - 2004 – Pentium IV All versions are backwards compatible 5 IBCM vs. x86 • Registers • Fetch-Execute cycle 6 Registers in x86 7 Fetch Execute Cycle (same) while(power is on) { IR := mem[PC] PC := PC + 1 (word) // 32-bits in x86 execute instruction in IR } PC = program counter IR = instruction register 8 End of lecture on Mon, Mar 16 • Also went over slides 34-46 of 08-ibcm 9 Declaring Variables in x86 • Directives byte = 1 byte ( DB ) declare byte word = 2 bytes ( DW ) double = 4 bytes ( DD ) quadword = 8 bytes ( DQ ) .DATA a DB 23 b DW ? c DD 3000 d DQ-800 x DD 1, 2, 3 y DB 8 DUP(0) str DB `hello’, 0 z DD 50 DUP(?) x DUP (y) directive means: “repeat y, x times” 10 mov command • mov <dest> <src> • Where <dest> and <src> can be: – A register – A combination of registers and constants – Variable name – Pointer: [ebx] 11 Addressing Memory • Up to 2 registers and one 32-bit signed constant can be added together to compute a memory address • One register can be pre- multiplied by 2, 4, 8 – word-align – double-align – quadword-align mov eax, ebx move eax, [ebx] mov [var], ebx mov eax, [esi -4] mov [esi+eax], cl mov edx, [esi+ 4*ebx ] Incorrect: (why?) mov eax, [ebx – ecx] mov [eax + esi + edi], ebx mov [4*eax + 2*ebx], ecx 12 Example mov ecx, eax mov edx, [ebx] mov esi, [edx+eax+4] mov [esi], 45 mov [a], 15 lea edi, [a] 100 16 8 3 200 Memory Address 104 i: 108 112 116 200 204 a: 300 304 eax ebx ecx edx esi edi 100 45 15 104 100 8 200 300 8 200 13 mov eax, [4*esi - edx] 1. Valid 2. Invalid 3. Not sure 14 mov eax, [4*esi + 4] 1. Valid 2. Invalid 3. Not sure 15 mov eax, [4*esi + edx+ 8] 1. Valid 2. Invalid 3. Not sure 16 mov eax, [esi + 4*edx] 1. Valid 2. Invalid 3. Not sure 17 mov eax + 4, [esi] 1. Valid 2. Invalid 3. Not sure 18 x86 Instruction Set • Data movement instructions • Arithmetic instructions • Logical instructions • Control instructions 19 Data Movement Instructions • mov • push – push operand onto stack (4 bytes) • First decrements ESP (stack pointer) by 4 (stack grows DOWN) • push eax • push [var] • pop – pop top element of stack to memory or register, increment stack pointer (ESP ) by 4 • lea (load effective address) – place address specified – lea eax, [var] – lea edi, [ebx+4*esi] 20...
View Full Document

This note was uploaded on 09/11/2009 for the course CS 216 taught by Professor Bloomfield during the Spring '08 term at UVA.

Page1 / 92

09-x86 - 1 Introduction to x86 Part 1 CS216: Program and...

This preview shows document pages 1 - 20. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online