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

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

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

3.1 DATA MOVEMENT INSTRUCTIONS 45

Basic Pentium Instructions. October 18

Instructions moving data

Computer Architecture and Assembly Language. Practical Session 3

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

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

Computer Architecture and System Programming Laboratory. TA Session 3

Week /8086 Microprocessor Programming I

Defining and Using Simple Data Types

16.317: Microprocessor Systems Design I Fall 2013

EECE.3170: Microprocessor Systems Design I Spring 2016

Basic Assembly Instructions

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

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

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.

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

Logical and Bit Operations. Chapter 8 S. Dandamudi

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.

8088/8086 Programming Integer Instructions and Computations

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

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

Basic Execution Environment

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

Arithmetic and Logic Instructions And Programs

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

Chapter Four Instructions Set

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

The x86 Architecture

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

8086 INSTRUCTION SET

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

Intel 8086: Instruction Set

Summer 2003 Lecture 4 06/14/03

Lab 3. The Art of Assembly Language (II)

Introduction to 8086 Assembly

Arithmetic Instructions

SOEN228, Winter Revision 1.2 Date: October 25,

Assembly Language: IA-32 Instructions

Architecture and components of Computer System Execution of program instructions

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

16.317: Microprocessor Systems Design I Fall 2015

Signed number Arithmetic. Negative number is represented as

Logical and bit operations

16.317: Microprocessor Systems Design I Spring 2014

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

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

Lecture (08) x86 programming 7

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

16.317: Microprocessor Systems Design I Fall 2014

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

Module 3 Instruction Set Architecture (ISA)

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

16.317: Microprocessor Systems Design I Spring 2015

Code segment Stack segment

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

Computer Department Chapter 7. Created By: Eng. Ahmed M. Ayash Modified and Presented by: Eng. Eihab S. El-Radie. Chapter 7

Lecture 2 Assembly Language

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Chapter 7 Integer Arithmetic

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

An Introduction to x86 ASM

Introduction to IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

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

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

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

CS241 Computer Organization Spring 2015 IA

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

EC 333 Microprocessor and Interfacing Techniques (3+1)

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

PESIT Bangalore South Campus

1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M. 2 PUSH/ POP R16/M16/SR/F 2 x ( ) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M

Complex Instruction Set Computer (CISC)

Practical Malware Analysis

Week /8086 Microprocessor Programming

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION 80x86 Instructions

COMPUTER ENGINEERING DEPARTMENT

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

X86-NASM STANDARD COMMANDS. Comment your code with a semicolon (;)! The assembler won t read anything after it.

ADVANCE MICROPROCESSOR & INTERFACING

CMSC 313 Lecture 05 [draft]

Basic Intel x86 Assembly Language Programming

Mnem. Meaning Format Operation Flags affected ADD Addition ADD D,S (D) (S)+(D) (CF) Carry ADC Add with ADC D,C (D) (S)+(D)+(CF) O,S,Z,A,P,C

Kingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 5

Microprocessors ( ) Fall 2010/2011 Lecture Notes # 15. Stack Operations. 10 top

Assembly Language Lab # 9

Lab 4: Basic Instructions and Addressing Modes

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

Chapter 12. Selected Pentium Instructions

Program Exploitation Intro

Conditional Processing

ASSEMBLY LANGUAGE PROGRAMMING OF THE MICROCOMPUTER

Computer Architecture Prof. Smruti Ranjan Sarangi Department of Computer Science and Engineering Indian Institute of Technology, Delhi

x64 Cheat Sheet Fall 2014

Transcription:

The following pages contain references for use during the exam: tables containing the x86 instruction set (covered so far) and condition codes. You do not need to submit these pages when you finish your exam. Remember that: Most instructions can have at most one memory operand. Brackets [ ] around a register name, immediate, or combination of the two indicates an effective address. o Example: MOV AX, [0x10] à contents of address 0x10 moved to AX Parentheses around an address mean the contents of memory at this address. o Example: (0x10) à the contents of memory at address 0x10 Category Instruction Example Meaning Move MOV AX, BX AX = BX Move & sign-extend MOVSX EAX, DL EAX = DL, sign-extended to 32 bits Data transfer Move and zero-extend MOVZX EAX, DL EAX = DL, zero-extended to 32 bits Exchange XCHG AX, BX Swap contents of AX, BX Load effective LEA AX,[BX+SI+0x10] AX = BX + SI + 0x10 address Add ADD AX, BX AX = AX + BX Add with carry ADC AX, BX AX = AX + BX + CF Increment INC [EDI] (EDI) = (EDI) + 1 Subtract SUB AX, [0x10] AX = AX (0x10) Subtract with borrow SBB AX, [0x10] AX = AX (0x10) CF Decrement DEC CX CX = CX 1 Negate (2 s NEG CX CX = -CX Arithmetic complement) Multiply Unsigned: MUL (all operands are nonnegative) Signed: IMUL (all operands are signed integers in 2 s complement form) Divide Unsigned: DIV (all operands are nonnegative) Signed: IDIV (all operands are signed integers in 2 s complement form) IMUL BH IMUL CX MUL DWORD PTR [0x10] DIV BH IDIV CX DIV EBX AX = BH * AL (DX,AX) = CX * AX (EDX,EAX) = (0x10) * EAX AL = AX / BH (quotient) AH = AX % BH (remainder) AX = EAX / CX (quotient) DX = EAX % CX (remainder) EAX = (EDX,EAX) / EBX (Q) EDX = (EDX,EAX) % EBX (R) 1

Category Instruction Example Meaning Logical AND AND AX, BX AX = AX & BX Logical Logical inclusive OR OR AX, BX AX = AX BX Logical exclusive OR XOR AX, BX AX = AX ^ BX Logical NOT (bit flip) NOT AX AX = ~AX Shift left SHL AX, 7 AX = AX << 7 Shift/rotate (NOTE: for all instructions except RCL/RCR, CF = last bit shifted out) Bit test/ scan Logical shift right (treat value as unsigned, shift in 0s) Arithmetic shift right (treat value as signed; SAL AX, CX AX = AX << CX SHR AX, 7 AX = AX >> 7 (upper 7 bits = 0) SAR AX, 7 AX = AX >> 7 (upper 7 bits = MSB of original value) maintain sign) Rotate left ROL AX, 7 AX = AX rotated left by 7 (lower 7 bits of AX = upper 7 bits of original value) Rotate right ROR AX, 7 AX=AX rotated right by 7 (upper 7 bits of AX = lower 7 bits of original value) Rotate left through carry Rotate right through carry RCL AX, 7 (CF,AX) rotated left by 7 (Treat CF & AX as 17-bit value with CF as MSB) RCR AX, 7 (AX,CX) rotated right 7 (Treat CF & AX as 17-b8t value with CF as LSB) Bit test BT AX, 7 CF = Value of bit 7 of AX Bit test and reset BTR AX, 7 CF = Value of bit 7 of AX Bit 7 of AX = 0 Bit test and set BTS AX, 7 CF = Value of bit 7 of AX Bit 7 of AX = 1 Bit test and complement BTC AX, 7 CF = Value of bit 7 of AX Bit 7 of AX is flipped Bit scan forward BSF DX, AX DX = index of first nonzero bit of AX, starting with bit 0 ZF = 0 if AX = 0, 1 otherwise Bit scan reverse BSR DX, AX DX = index of first nonzero bit of AX, starting with MSB ZF = 0 if AX = 0, 1 otherwise 2

Category Instruction Example Meaning Conditional Compare CMP AX, BX Subtract AX BX Updates flags tests Byte set on condition SETcc AH AH = 1 if condition true AH = 0 if condition false Unconditional jump JMP label Jump to label Conditional jump Jcc label Jump to label if condition true Loop LOOP label Decrement CX; jump to Jumps and loops Loop if equal/zero Loop if not equal/zero LOOPE label LOOPZ label LOOPNE label LOOPNZ label label if CX!= 0 Decrement CX; jump to label if (CX!= 0) && (ZF == 1) Decrement CX; jump to label if (CX!= 0) && (ZF == 0) Call subroutine CALL label Jump to label; save address of instruction after CALL Return from subroutine Push RET label PUSH AX Return from subroutine (jump to saved address from CALL) SP = SP 2 (SP) = AX Subroutinerelated instructions Pop PUSH EAX POP AX SP = SP 4 (SP) = EAX AX = (SP) SP = SP + 2 POP EAX EAX = (SP) SP = SP + 4 Push flags PUSHF Store flags on stack Pop flags POPF Remove flags from stack Push all registers PUSHA Store all general purpose registers on stack Pop all registers POPA Remove general purpose registers from stack 3

Condition code Meaning Flags O Overflow OF = 1 NO No overflow OF = 0 B NAE C Below Not above or equal Carry CF = 1 NB AE NC Not below Above or equal No carry CF = 0 S Sign set SF = 1 NS Sign not set SF = 0 P Parity PF = 1 PE Parity even NP No parity PF = 0 PO Parity odd E Equal ZF = 1 Z Zero NE Not equal ZF = 0 NZ Not zero BE Below or equal CF OR ZF = 1 NA Not above NBE Not below or equal CF OR ZF = 0 A Above L Less than SF XOR OF = 1 NGE Not greater than or equal NL Not less than SF XOR OF = 0 GE Greater than or equal LE Less than or equal (SF XOR OF) OR ZF = 1 NG Not greater than NLE Not less than or equal (SF XOR OF) OR ZF = 0 G Greater than 4

x86 subroutine details: Subroutine arguments are passed on the stack, and can be accessed within the body of the subroutine starting at address EBP+8. At the start of each subroutine: o Save EBP on the stack o Copy the current value of the stack pointer (ESP) to EBP o Create space within the stack for each local variable by subtracting the appropriate value from ESP. For example, if your function uses four integer local variables, each of which contains four bytes, subtract 16 from ESP. Local variables can then be accessed starting at the address EBP-4. o Save any registers the function uses other than EAX, ECX, and EDX. A subroutine s return value is typically stored in EAX. Typical x86 stack frame (covered in HLL à assembly lectures) Lower addresses Higher addresses saved register n saved registers saved register 1 local variable n local variables local variable 2 local variable 1 saved EBP saved EIP (return address) fn argument 1 fn argument 2 function arguments fn argument n EBP-4n EBP-8 EBP-4 EBP+8 EBP+12 EBP+4n+4 ESP EBP 5

The following two pages contain tables listing the PIC 16F1829 instruction set. You do not need to submit these pages with your exam. Remember that, in the table below: f = a register file address W = the working register d = destination select: F for a file register, W for the working register b = bit position within an 8-bit file register k = literal field, constant data or label PC = the program counter C = the carry bit in the status register Z = the zero bit in the status register 6

Source for table: PIC16(L)F1825/1829 Data Sheet, Microchip Technology, Inc. http://ww1.microchip.com/downloads/en/devicedoc/41440c.pdf 7