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.

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

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

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

Arithmetic and Logic Instructions And Programs

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

Chapter Four Instructions Set

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.

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Signed number Arithmetic. Negative number is represented as

Basic Assembly SYSC-3006

Basic Pentium Instructions. October 18

8088/8086 Programming Integer Instructions and Computations

Intel 8086: Instruction Set

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Week /8086 Microprocessor Programming I

Introduction to 8086 Assembly

8086 INSTRUCTION SET

Microprocessor & Computer Architecture / Lecture

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

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

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

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

Code segment Stack segment

Instructions moving data

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Lecture (08) x86 programming 7

3.1 DATA MOVEMENT INSTRUCTIONS 45

Assignment no:4 on chapter no :3 : Instruction set of 8086

Chapter 12. Selected Pentium Instructions

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

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

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

Shift and Rotate Instructions

Logical and Bit Operations. Chapter 8 S. Dandamudi

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

8086 ASSEMBLY LANGUAGE PROGRAMMING

ASSEMBLY LANGUAGE PROGRAMMING OF THE MICROCOMPUTER

UNIT III MICROPROCESSORS AND MICROCONTROLLERS MATERIAL OVERVIEW: Addressing Modes of Assembler Directives. Procedures and Macros

Summer 2003 Lecture 4 06/14/03

16.317: Microprocessor Systems Design I Fall 2013

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

8086 Micro-Processors and Assembly Programming Forth Stage المعالجات الميكروية والبرمجة بلغة التجميع استاذة الماده: م.د ستار حبيب منعثر الخفاجي

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

Intel 8086 MICROPROCESSOR ARCHITECTURE

Arithmetic Instructions

CMSC 313 Lecture 05 [draft]

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

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

PESIT Bangalore South Campus

Section 001. Read this before starting!

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

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

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB4 FÖYÜ

ADVANCE MICROPROCESSOR & INTERFACING

Week /8086 Microprocessor Programming II

Week /8086 Microprocessor Programming

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

Section 001 & 002. Read this before starting!

16.317: Microprocessor Systems Design I Spring 2014

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

8086 INTERNAL ARCHITECTURE

Intel 8086 MICROPROCESSOR. By Y V S Murthy

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

CS401 Assembly Language Solved MCQS From Midterm Papers

9/25/ Software & Hardware Architecture


icroprocessor istory of Microprocessor ntel 8086:

Lecture 5:8086 Outline: 1. introduction 2. execution unit 3. bus interface unit

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

Logical and bit operations

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : / N. a) Describe the function of SID and SOD pins of 8085 microprocessor

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Chapter 7 Integer Arithmetic

Assembly Language LAB

Lecture (07) x86 programming 6

CS241 Computer Organization Spring 2015 IA

Section 002. Read this before starting!

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

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

Basic Execution Environment

Mr. Sapan Naik 1. Babu Madhav Institute of Information Technology, UTU

Read this before starting!

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

Defining and Using Simple Data Types

b) List the 16 Bit register pairs of 8085?(Any 2 pair, 1 Mark each) 2M Ans: The valid 16 bit register pair of 8085 are

Microprocessor and Assembly Language Week-5. System Programming, BCS 6th, IBMS (2017)

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

EC 333 Microprocessor and Interfacing Techniques (3+1)

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

Section 001. Read this before starting!

Addressing Modes on the x86

if 2 16bit operands multiplied the result will be

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

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

International Islamic University Chittagong (IIUC) Department of Electrical and Electronic Engineering (EEE)

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

Architecture and components of Computer System Execution of program instructions

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

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

Transcription:

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. MOV AX, 5000H MOV DS, AX MOV AL, 20H MOV CL, 30H ADD AL, CL MOV CL, 10H MUL CL MOV SI, 4000H MOV [SI], AX HLT Ex: Write an ALP to multiply the word 1234H by the double word 12345678H. Store the result in locations starting in 54000H. MOV AX, 1234H MOV BX, 5678H MOV CX, 1234H MUL BX MOV SI, AX MOV DI, DX MOV AX, 1234H MUL CX ADC AX, DI ADC DX, 0000H MOV BX, 5000H MOV DS, BX MOV [4000H], SI MOV [4002H],AX MOV [4004H],DX HLT

Logical Instructions: This group includes AND, OR, XOR and NOT instructions. These instructions perform logic operations. They are used to clear, set, and complement certain bits in a register or a memory location. NOT Instruction gives the 1's complement of the operand ( ) NEG Instruction gives the 2's complement of the operand ( ) The allowed operands (AND, OR, XOR) NOT and NEG Examples AND AL, BL AND AX, [BX] OR [SI+1000], CL XOR AX, AX NOT DL NOT [2000] Note: After executing AND, OR, or XOR instructions CF and OF are both 0. PF, SF, and ZF are updated. AF is undefined. Ex : Write an ALP to clear bits 0 to 5, set bits 6 to 10 and complement bits 11 to 15 in a memory location 34000H. Ans. MOV AX, 3000H MOV DS, AX AND [4000], FFC0H OR [4000], 07C0H XOR [4000], F800H HLT

Shift Instructions: Shift instructions can perform two basic types of shift operations: the logical shift and the arithmetic shift. Also, each of these operations can be performed to the right or to the left. They have the ability to shift the contents of either an internal register or a storage location in memory. SHL D, 1 SHL D, CL SAL D, 1 SAL D, CL SHR D, 1 SHR D, CL SAR D, 1 SAR D, CL Shift D (Reg. / Mem.) to left either by 1 bit or by number of bits stored in CL. Shift D (Reg. / Mem.) to right either by 1 bit or by number of bits stored in CL. Shift D (Reg. / Mem.) either by 1 bit or by number of bits stored in CL. 8

Ex: If (AX)=1234H, then, executing: SHL AX, 1 (AX) = 2468H & (CF)=0 Ex: If (CL)=2 and (AX)= 1234AH. Then, executing: SAR AX, CL leads to: (AX)=048EH & (CF)=0 Rotate (ROL, ROR, RCL, and, RCR ) Instructions: Rotate instructions, are similar to the shift instructions. The operation of these instructions is described below. They have the ability to rotate the contents of either an internal register or a storage location in memory. ROL D, 1 ROL D, CL ROR D, 1 ROR D, CL RCL D, 1 RCL D, CL RCR D, 1 RCR D, CL Rotate D (Reg./Mem.) left out of carry either by 1 bit or No. of bits stored in CL. Rotate D (Reg./Mem.) right out of carry either by 1 bit or No. of bits stored in CL. Rotate D (Reg./Mem.) left through carry either by 1 bit or No. of bits in CL. The same operation of RCL but to the right. 0

Ex : If (CL) =04 16 and AX=1234A 16. Determine the new contents of AX and the carry flag after executing the instructions: a) ROL AX, 1 b) ROR AX, CL Ans. a) (AX) = 2468H and (CF) = 0 b) (AX) = 4123H and (CF)=1 9

Flags Control Instructions The flag control instruction affect the state of the flags directly, these instructions and their operation are listed below: LAHF instruction : Load (copy to) AH with the low byte the flag register. (AH) (Low byte of flag register) SAHF instruction : Store (copy) AH register to low byte of flag register. (Low byte of flag register) (AH) Ex: Write an ALP that complements the first byte of flags register. LAHF XOR AH, 0FFH SAHF HLT Compare CMP and TEST Instructions The following are the characteristics of CMP instruction: Can compare two 8-bit or two 16-bit numbers. Operands many reside in memory, a register in the CPU or be a part of an instruction. CMP is a subtraction method, it uses 2 s complement. Result of CMP is not saved in the destination operand. Results of comparison is reflected in the six status flags: CF, AF, OF, PF, SF and ZF. 8

Examples CMP AX, BX CMP DL, CL CMP AL, [BX] CMP CX, 1234h CMP [SI+100H], 1234H The TEST Instruction This instruction ANDs the contents of a source byte or word with the contents of specified destination word. Flags are updated but neither operand is changed. TEST instruction is often used to set flags before a conditional jump instruction. Mnemonic Meaning Format Operation Flags Affected TEST test TEST D, S (D). (S) PF, ZF, SF

Program Control Instructions Branch Instructions (Jump) There are two basic types of jump: The Intra-segment jump is a jump within the current code segment. It is achieved by only modifying the value of IP. The Inter-segment jump is a jump from one segment to another, both CS and IP values are to be modified. Unconditional and Conditional Jump Unconditional Jump (JMP) Specifies a new value of IP with an 8-bit immediate operand. Specifies a new value of IP with a 16-bit immediate operand. Specifies a new value of IP and A new segment. Specifies a new value of IP with the content of a 16-bit memory operand. Specifies a new value of IP with the content of a 16-bit Reg. operand. Specifies a new value of IP with the content of a 32-bit memory operand. Short-label, Near-label, Memptr16 or Regptr16 types of operands represent intra-segment jump. Far-label and Memptr32 represent inter-segment jump.