Basic Pentium Instructions. October 18

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

Instructions moving data

Ex : Write an ALP to evaluate x(y + z) where x = 10H, y = 20H and z = 30H and store the result in a memory location 54000H.

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100

ECOM Computer Organization and Assembly Language. Computer Engineering Department CHAPTER 7. Integer Arithmetic

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

8086 Programming. Multiplication Instructions. Multiplication can be performed on signed and unsigned numbers.

Reverse Engineering Low Level Software. CS5375 Software Reverse Engineering Dr. Jaime C. Acosta

Q1: Multiple choice / 20 Q2: Protected mode memory accesses

We will first study the basic instructions for doing multiplications and divisions

Computer Architecture and Assembly Language. Practical Session 3

16.317: Microprocessor Systems Design I Spring 2014

Chapter 7 Integer Arithmetic

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB

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

Integer Arithmetic. Shift and rotate. Overview. Shift and Rotate Instructions

EECE.3170: Microprocessor Systems Design I Spring 2016

Defining and Using Simple Data Types

Integer Arithmetic. Pu-Jen Cheng. Adapted from the slides prepared by Kip Irvine for the book, Assembly Language for Intel-Based Computers, 5th Ed.

Q1: Multiple choice / 20 Q2: Data transfers and memory addressing

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

CMSC 313 Lecture 07. Short vs Near Jumps Logical (bit manipulation) Instructions AND, OR, NOT, SHL, SHR, SAL, SAR, ROL, ROR, RCL, RCR

Week /8086 Microprocessor Programming I

Computer Architecture and System Programming Laboratory. TA Session 3

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 21: Generating Pentium Code 10 March 08

22 Assembly Language for Intel-Based Computers, 4th Edition. 3. Each edge is a transition from one state to another, caused by some input.

16.317: Microprocessor Systems Design I Fall 2013

Integer Arithmetic Part2

Basic Assembly Instructions

Lecture 9. INC and DEC. INC/DEC Examples ADD. ADD Examples SUB. INC adds one to a single operand DEC decrements one from a single operand

Logic Instructions. Basic Logic Instructions (AND, OR, XOR, TEST, NOT, NEG) Shift and Rotate instructions (SHL, SAL, SHR, SAR) Segment 4A

Lecture 2 Assembly Language

Lab 3. The Art of Assembly Language (II)

SOEN228, Winter Revision 1.2 Date: October 25,

3.1 DATA MOVEMENT INSTRUCTIONS 45

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

COMPUTER ENGINEERING DEPARTMENT

Integer Arithmetic. Computer Organization and Assembly Languages Yung-Yu Chuang 2005/11/17. with slides by Kip Irvine

Signed number Arithmetic. Negative number is represented as

Introduction to 8086 Assembly

Logical and Bit Operations. Chapter 8 S. Dandamudi

Introduction to 8086 Assembly

Computer Science Final Examination Wednesday December 13 th 2006

8088/8086 Programming Integer Instructions and Computations

The x86 Architecture

Adding Binary Integers. Part 5. Adding Base 10 Numbers. Adding 2's Complement. Adding Binary Example = 10. Arithmetic Logic Unit

/ 30 Q3: Arithmetic instructions / 30 Q4: Logical instructions / 20 TOTAL SCORE / 100 Q5: EXTRA CREDIT / 10

CSC201, SECTION 002, Fall 2000: Homework Assignment #3

CMSC 313 Lecture 05 [draft]

Chapter 5. Real-Mode 80386DX Microprocessor Programming 1 Part 2. The 80386, 80486, and Prentium Processors,Triebel Prof. Yan Luo, UMass Lowell 1

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2016 Lecture 12

Intel 8086: Instruction Set

CS241 Computer Organization Spring 2015 IA

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 5

Arithmetic and Logic Instructions And Programs

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

Program Exploitation Intro

from WRITE GREAT CODE Volume 2: Thinking Low-Level, Writing High-Level ONLINE APPENDIX A The Minimal 80x86 Instruction Set by Randall Hyde

Lab Session 08. To understand the use of Shift and Rotate instructions. To be able to differentiate between Arithmetic shift and Logical shift.

Assembler lecture 4 S.Šimoňák, DCI FEEI TU of Košice

StarForce 3 - Brief insight into a hidden world. By [yates] [ [

Chapter 12. Selected Pentium Instructions

Week /8086 Microprocessor Programming

Practical Malware Analysis

Module 3 Instruction Set Architecture (ISA)

CSE P 501 Compilers. x86 Lite for Compiler Writers Hal Perkins Autumn /25/ Hal Perkins & UW CSE J-1

Computer Systems Organization V Fall 2009

Arithmetic Instructions

Q1: Multiple choice / 20 Q2: Memory addressing / 40 Q3: Assembly language / 40 TOTAL SCORE / 100

UNIT II. 2 Marks. 2. List out the various register of IA- 32 Register structure. 3. Write about General purpose registers

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

Basic Assembly SYSC-3006

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

Lecture (08) x86 programming 7

A CRASH COURSE IN X86 DISASSEMBLY

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

Assembly Language: IA-32 Instructions

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

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

16.317: Microprocessor Systems Design I Fall 2014

Step 1: Add the least significant digits together: produces with carry 1.

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

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

COMPUTER ENGINEERING DEPARTMENT

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

ELEC 242 Time Delay Procedure

ADDRESSING MODES. Operands specify the data to be used by an instruction

Bit Operations. Ned Nedialkov. McMaster University Canada. SE 3F03 February 2014

Microprocessor & Computer Architecture / Lecture

x64 Cheat Sheet Fall 2014

CPS104 Recitation: Assembly Programming

Adding Binary Integers. Part 4. Negative Binary. Integers. Adding Base 10 Numbers. Adding Binary Example = 10. Arithmetic Logic Unit

Lecture 9. INC and DEC. INC/DEC Examples ADD. Arithmetic Operations Overflow Multiply and Divide

Lab 4: Basic Instructions and Addressing Modes

Conditional Processing

CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK

Shift and Rotate Instructions

Summer 2003 Lecture 4 06/14/03

Week /8086 Microprocessor Programming II

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

Transcription:

Basic Pentium Instructions October 18 CSC201 Section 002 Fall, 2000

The EFLAGS Register Bit 11 = Overflow Flag Bit 7 = Sign Flag Bit 6 = Zero Flag Bit 0 = Carry Flag "Sets the flags" means sets OF, ZF, SF, CF in the "normal" way CSC201 Section Copyright 2000, Douglas Reeves 2

Operand Types and Notation Register operands reg (= reg32), reg8 Memory operands mem (= mem32), mem8 Any memory addressing mode allowed unless specified otherwise Immediate values imm (=imm32), imm8 CSC201 Section Copyright 2000, Douglas Reeves 3

"mov"" Instruction Operand combinations: reg/mem, reg/imm "mov "mov "mov EAX, EBX" EAX, 0A34H" [EBP+4], EAX" "mov myvar, 022334455h" Another combination: reg, mem "mov EAX, myvar" 8-bit versions of all of the above No effect on flags CSC201 Section Copyright 2000, Douglas Reeves 4

"movsx"" and "movzx" movzx" " Instructions Operands combination: reg, reg8/mem8 "movsx "movsx EAX, BL" EAX, mychar1" No effect on flags CSC201 Section Copyright 2000, Douglas Reeves 5

"lea" Instruction Operand combination: reg, mem "lea "lea EBP, myvar" EBP, [myvar+5]" No effect on flags CSC201 Section Copyright 2000, Douglas Reeves 6

Push and Pop Push Operand combination: reg/mem/imm push EAX push [ESI+4] push 22AAFF33h Can also push a byte-length immediate Pop Operand combination: reg/mem pop EAX pop myvar Cannot pop byte-length operands CSC201 Section Copyright 2000, Douglas Reeves 7

"add" and "sub" Instructions Operands: reg/mem, reg/imm "add myvar, ECX" "sub EBX, -22" Another combination: reg, mem "add EAX, myvar" 8-bit versions of the above Setting of the flags... Overflow detect (OF) assumes operands are twos-complement numbers Unsigned overflow detect: use CF instead CSC201 Section Copyright 2000, Douglas Reeves 8

cmp"" Instruction Same as "sub", but result value not stored in first operand Only sets the flags CSC201 Section Copyright 2000, Douglas Reeves 9

"inc" and "sub" Instructions Operand combination: reg/mem Like "add operand, 1" and "sub operand, 1" 8-bit versions of the above Sets the flags Overflow detect assumes operand is twos-complement number Does not affect CF; unsigned overflow detect not possible CSC201 Section Copyright 2000, Douglas Reeves 10

"neg"" Instruction Two's-complement a number Operands: reg / mem "neg EAX" 8-bit versions of the above Sets the flags CSC201 Section Copyright 2000, Douglas Reeves 11

"mul"" Instruction *Unsigned* multiply Operand combination: reg/mem Meaning: EDX:EAX <-- EAX * reg (or mem) mul mul EBX mydw1 (There is an 8-bit version we will not use) Only useful flag: CF = 0 means DX = 0, otherwise CF = 1 CSC201 Section Copyright 2000, Douglas Reeves 12

"imul"" Instruction *Signed* multiply One-address, two-address, and three-address formats! Operands: reg/mem EDX:EAX <-- EAX * reg (or mem) mul EBX Operands: reg, reg/mem reg <-- reg * reg (or mem) mul EAX, myvar CSC201 Section Copyright 2000, Douglas Reeves 13

"imul"" Instruction Operand combination: reg, reg/mem, imm reg <-- reg (or mem) * imm mul EAX, myvar, 55 (There is an 8-bit version we will not use) Only useful flag: CF = 0 means result fits in EAX alone (or destination register), CF = 1 otherwise CSC201 Section Copyright 2000, Douglas Reeves 14

"div" Instruction *Unsigned* divide Operand combination: reg/mem EDX <-- remainder of EDX:EAX / reg (or mem), EAX <-- quotient div EBX (There is an 8-bit version we will not use) No effect on flags, but check for divide by zero (or overflow) possibility first! Will generate an exception (program halts) if you don't catch it CSC201 Section Copyright 2000, Douglas Reeves 15

"idiv"" Instruction *Signed* divide Otherwise, same as "div" CSC201 Section Copyright 2000, Douglas Reeves 16

"not" Instruction operand: reg/mem "not [EAX+35]" 8-bit version also no effect on flags CSC201 Section Copyright 2000, Douglas Reeves 17

"or", "and", "xor" xor", and "test" Instructions operands: reg/mem, reg/imm or EAX, EDX reg, mem or EAX, myvar 8-bit versions also affects SF and ZF (not CF or OF) "test" only affects the flags, no result stored Note: xor'ing a value with itself clears it to 0; programming trick! CSC201 Section Copyright 2000, Douglas Reeves 18

"shr", "sar" sar", "shl" shl" " and "sal" sal" Instructions operands: reg/mem, cl/imm8 sar dword ptr [EBP 8], 1 shr EAX, CL cl and imm8 should have a value between 0 and 31 shr does zero fill, sar does sign extension shl and sar do same thing 8-bit versions also (but imm8 can only = 1) affects ZF, SF, and CF shr and sar: CF = least-significant-bit (before shifting) shl and sal: CF = most-significant-bit (before shifting) CSC201 Section Copyright 2000, Douglas Reeves 19

"rol"" and "ror" ror" " Instructions operands: reg/mem, cl/imm8 ror dword ptr [EBX], 4 rol EAX, CL cl and imm8 should have a value between 0 and 31 8-bit versions also (but imm8 can only = 1) affects ZF, SF, and CF ror: CF = least-significant-bit (before shifting) rol: CF = most-significant-bit (before shifting) CSC201 Section Copyright 2000, Douglas Reeves 20