The x86 Instruction Set Lecture 16 Mon, Mar 14, 2005.

Slides:



Advertisements
Similar presentations
Machine Instructions Operations
Advertisements

There are two types of addressing schemes:
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Department of Computer Science and Software Engineering
KMUTT: S. Srakaew Instructions Can Be Divided into 3 Classes Data movement instructions  Move data from a memory location or register to another memory.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
1 Lecture 5: Procedures Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Accessing parameters from the stack and calling functions.
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.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
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.
Stacks and Frames Demystified CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Processor Organization and Architecture Module III.
Lecture 18 Last Lecture Today’s Topic Instruction formats
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 7 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Y86 Processor State Program Registers
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
The 8051 Microcontroller and Embedded Systems
Code Generation Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013.
Memory and Addressing How and Where Information is Stored.
Multiplication and Division Instructions & the 0Ah function.
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
Today’s topics Procedures Procedures Passing values to/from procedures Passing values to/from procedures Saving registers Saving registers Documenting.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Procedures – Generating the Code Lecture 21 Mon, Apr 4, 2005.
Sahar Mosleh California State University San MarcosPage 1 Stack operations, Applications and defining procedures.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Decision Structures – Code Generation Lecture 24 Mon, Apr 18, 2005.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Arithmetic and Logic Instructions
What is a program? A sequence of steps
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
ICS 312 SET 10 Multiplication & Division & input using function 0Ah.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
1 Assembly Language: Function Calls Jennifer Rexford.
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.
Improvements to the Compiler Lecture 27 Mon, Apr 26, 2004.
Khaled A. Al-Utaibi  Introduction  The MOV Instruction  The LEA Instruction  The Stack Instructions  The String Data Transfer.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Displacement (Indexed) Stack
CHAPTER ADDRESSING MODES.
C function call conventions and the stack
Data Transfers, Addressing, and Arithmetic
Classification of Instruction Set of 8051
Introduction to Compilers Tim Teitelbaum
8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.
A Closer Look at Instruction Set Architectures: Expanding Opcodes
Chapter 3 Addressing Modes
Computer Organization and Assembly Language (COAL)
3.5 Programming paradigms
Additional data transfer and 16 bit arithmetic instruction Lecture 1
Y86 Processor State Program Registers
BIC 10503: COMPUTER ARCHITECTURE
Stack Frames and Advanced Procedures
Procedures – Overview Lecture 19 Mon, Mar 28, 2005.
Practical Session 4.
68000 Architecture, Data Types and Addressing Modes
ECEG-3202 Computer Architecture and Organization
Chapter 6 - Procedures and Macros
ECEG-3202 Computer Architecture and Organization
X86 Assembly Review.
Computer Organization and Assembly Language
(The Stack and Procedures)
Presentation transcript:

The x86 Instruction Set Lecture 16 Mon, Mar 14, 2005

The Instruction Set A table of x86 instructions:

The Runtime Stack The runtime stack is a portion of memory that is used as a stack during program execution. The address of the top of the stack is stored in the register esp, called the stack pointer. The stack grows in a “downward” direction. When values are pushed, esp is decremented. When values are popped, esp is incremented.

The Runtime Stack esp points to the “top” of the stack. Stack esp

The Runtime Stack Push a value and decrement esp. Stack esp

The Runtime Stack Push another value and decrement esp again. Stack esp

The Runtime Stack Pop a value and increment esp. Stack esp

The Runtime Stack Pop another value and increment esp again. Stack esp

The Push and Pop Instructions The push and pop instructions have the format push source pop destination source is a register, a memory address, or an immediate value. destination is a register or a memory address.

The Push and Pop Instructions The push instruction will decrement the stack pointer and then move source to the stack. The pop instruction will move the value on the stack to destination and then increment the stack pointer.

Processing the Syntax Tree The syntax tree is processed in a left-to-right post-order traversal. At each node Process the left subtree. Process the right subtree. Process the node.

Using the Stack As each node of the syntax tree is executed, it will leave its result on the run-time stack. The next node will pop that result off the stack (if it needs it) and then push its own result onto the stack, and so on.

Example The syntax tree for a = b + c – 5 is ASSIGN MINUS ID a PLUS DEREF NUM 5 DEREF ID b ID c

Example Order of execution ID – Push the address of a. ID – Push the address of b. DEREF – Push the value of b. ID – Push the address of c. DEREF – Push the value of c. PLUS – Pop two values, add them, push the result. NUM – Push 5. MINUS – Pop two values, subtract them, push the result. ASSIGN – Pop the value and the address, store the value at the address, push the result.

A NUM Node A NUM node loads the integer whose value is stored in the node. For example, to load 5: push $5 The $ sign means the “immediate” value 5.

An ID Node A ID node pushes the address of the name that is stored in the node. For example, to push the address a : lea a,%eax push %eax The instruction “ push a ” would not push the address of a ; it would push the value at address of a, i.e., the value of a, which is not what we want.

A DEREF Node A DEREF node expects to find a memory address on top of the stack. It pushes the value stored at that address. pop %eax push (%eax) The parentheses mean “the value at the address in the register.” This is the indirect addressing mode.

The Add Instruction The add instruction has the format add source,destination The value at source is added to the value at destination and the result is stored at destination. source is a register, a memory address, or an immediate value. destination is a register or a memory address.

A PLUS Node A PLUS node expects to find two numbers on the stack. The right operand should be on top. It pops the values, adds them, and pushes the result. pop %edx pop %eax add %edx,%eax push %eax

An ASSIGN Node An ASSIGN node expects to find an address and a value on the stack. The value should be on top. It pops the value and the address, stores the value at the address, and pushes the value. pop %eax pop %edx mov %eax,(%edx) push %eax

The imul Instruction The imul instruction performs multiplication of signed integers. The first format imul source source is one operand. eax is the other operand. The destination is edx:eax, which holds a 64-bit value.

The imul Instruction The second format imul register,source source is one operand. It is a register, a memory address, or an immediate value. register is the other operand and the destination.

The imul Instruction The third format imul register,source,immediate register is the destination. source is one operand. It is a register, a memory address, or an immediate value. immediate is the other operand.

A TIMES Node A TIMES node expects to find two values on the stack. It pops them, multiplies them, and pushes the result. pop %eax pop %ecx imul %ecx push %eax