8086 microprocesser instructions

22
…..Multiplicative .. ..Instruction s..

Upload: jsaddam709

Post on 16-Oct-2014

661 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 8086 Microprocesser Instructions

…..Multiplicative….. ..Instructions..

Page 2: 8086 Microprocesser Instructions

o An Integrated chip with the multi programmable capability.o It is a general purpose chip with some integrated memory as

well processing unit.o The normal computers have a microprocessor with some

external central processing units. It is

called microcomputer.o Speed of the microprocessor

decided by the number of clock

cycles passed for an instruction

execution.

Microprocessor Just an intro

i8086

Page 3: 8086 Microprocesser Instructions

o The purpose of microcontroller is a specific.o Normally the embedded system applications developed by

using microcontroller.

Microcontroller Just an intro

Page 4: 8086 Microprocesser Instructions

o The macro instructions introduced to increase the flexibility of the programmer and to reduce the code size.

o The macro instructions will be converted as micro instructions. That will only understandable by the machine.

o The micro instructions will have the micro level operation with the control function. Such as register movement, fetch, memory read.

Macro instructions/Micro instructions

Page 5: 8086 Microprocesser Instructions

o Arithmetic instructions (ADD, SUB, MUL, DIV)o Logical Instructions (AND, OR, XOR)o Register transfer instructions (MOV, XCHG)o Shift instructions (SHL, SHR)o Rotate Instructions (ROR, ROL, RCL, RCR)o The Bit operation (TEST)o I/O instructions (IN, OUT)o String instructions (MOVS, LODS)o Program flow control instructions (JMP, CALL, RET, HLT)

The Instructions type in 8086

Page 6: 8086 Microprocesser Instructions

MUL (unsigned Multiplication)

o This MUL instruction used to multiply the unsigned number.o The Multiplication is manually can be done by repeated

addition.

Syntax : MUL operand

Operand may be reg/mem : 8/16

for 8bit (byte multiplication)

AX := AL*operand; AL is a silent operand

opcode : F6

for 16bits operands (byte multiplication)

AX :DX = AX*operand; AX is a silent operand

opcode : F7

cntd.....

Page 7: 8086 Microprocesser Instructions

The basic principle is,

for n-bit multiplication the result range must exceed the limit of n-bits. So, 2*n bits allotted to store the result.

Flags affected : CF ,OF

Operand Clock cycles Instruction size(bytes)

8-bit Reg 70 – 77 2

16-bit Reg 118 – 133 2

8-bit Mem (76 – 83) + EA 2-4

16-bit Mem (124 – 139) + EA 2-4

Instruction code format : 1111011w mod100r/m

Page 8: 8086 Microprocesser Instructions

Example …

MOV AL,100MOV BL,10SUB AH,AHMUL BL ;AXAL*BL AX 03 E8h(100010)

;opcode : F6 E3 ;11 100 011---------------------------------------------------------------------------MOV AX,2048MOV BX,90MUL BX ;CF & OF flags set to 1 ; 184320

; AL00 AHD0 DL02 DX 002^17=131072 AX=184320-131072=53248 (D0 00 h);opcode : F7 E3 ;11 100 011

Page 9: 8086 Microprocesser Instructions

IMUL (signed Multiplication)

o IMUL instruction used for the signed multiplication.o Syntax : IMUL operand

Operand may be reg/mem : 8/16

for 8bit (byte multiplication)

AX := AL*operand; AL is a silent operand

opcode : F6

for 16 bits (Word multiplication)

AX:DX = AX*operand ;AX is a silent operand

opcode : F7

cntd…..

Page 10: 8086 Microprocesser Instructions

Flags affected : CF ,OF

Operand Clock cycles Instruction size(bytes)

8-bit Reg 80-98 2

16-bit Reg 128 – 154 2

8-bit Mem (86 – 104) + EA 2-4

16-bit Mem (134 – 160) + EA 2-4

Instruction format : 1111011w mod101r/m

Page 11: 8086 Microprocesser Instructions

Example

MOV AL,-100MOV BL,10SUB AH,AHIMUL BL ;AXAL*BL AX F6 18h(-100010);MUL BL ; AX 06 18h(156010)

; Opcode : F6 EB ; 11 101 011--------------------------------------------------------------------------------B DB 23H,-03HMOV AX,00E2H ;-30MOV BX,OFFSET B MOV CL,[BX+1]IMUL BYTEPTR[BX+1] ;AX=AL*(-3); AX 5A ;(90)

;opcode : F6 6F 01 ;01 10 1 111

Page 12: 8086 Microprocesser Instructions

DIV (unsigned Division)

o DIV instruction performs the unsigned division.o The division may be done by repeated subtraction.

Syntax : DIV operand; Operand may be reg/mem : 8/16

for 8bit (byte Manipulation)

AL = AX / operand; AX is a silent operand

AH = remainder (modulus)

opcode : F6

cntd…..

Page 13: 8086 Microprocesser Instructions

for 16 bits (Word multiplication)

AX = (DX AX) / operand; AX:DX is a silent operand

DX = remainder (modulus)

opcode : F7

AX must contain the dividend, DX be should be cleared before DIV instruction.

Flags Affected : CF ,OF ,SF ,PF

But the affection of the flags don’t have any valid usage.

Page 14: 8086 Microprocesser Instructions

Operand Clock cycles Instruction size(bytes)

8-bit Reg 80 - 90 2

16-bit Reg 144 - 162 2

8-bit Mem (86 – 96) + EA 2-4

16-bit Mem (150 – 168) + EA 2-4

Instruction format : 1111011w mod110r/m

Page 15: 8086 Microprocesser Instructions

Example

MOV AL,100MOV BL,11SUB AH,AHDIV BL ;ALAX/BL AHAX%BL

;AL 09 h AH 01 h

---------------------------------------------------------------------B DB 03HMOV AX,00E2H ;-30DIV B

;opcode : F6 36 00 00 ; 00 110 110

Page 16: 8086 Microprocesser Instructions

IDIV (signed Division)

o IDIV instruction performs the signed division.o The sign of the remainder is always same as the sign of the

dividend

Syntax : IDIV operand; Operand may be reg/mem : 8/16

for 8bit (byte manipulation)

AL = AX / operand; AX is a silent operand

AH = remainder (modulus)

opcode : F6

cntd…..

Page 17: 8086 Microprocesser Instructions

for 16 bits (Word multiplication)

AX = (DX AX) / operand; AX:DX is a silent operand

DX = remainder (modulus)

opcode : F7

Flags Affected : CF ,OF ,SF ,PF

Operand Clock cycles Instruction size(bytes)

8-bit Reg 101 – 112 2

16-bit Reg 165 – 184 2

8-bit Mem (107 – 118) + EA 2-4

16-bit Mem (171 – 190) + EA 2-4

Instruction code format : 1111011w mod111r/m

Page 18: 8086 Microprocesser Instructions

Example

MOV BL,-10 ;DIVISORMOV AX,101 ;DIVIDENDIDIV BL ; AH01 ALF6(-1010)

;opcode : F6 FB ;11 111 011;DIV BL ; AH65 AL00------------------------------------------------------------------------------------B DB 23H,-03HMOV AX,00E2H ;-30IDIV B

;opcode : F6 3E 00 00 ;00 11 1 110

Page 19: 8086 Microprocesser Instructions

Some extension…

Addressing mode mode bits

Register Addressing mode 11

Direct/register indirect/Based Index/Relative Based index 00

Register relative 01

This is for MUL , IMUL, DIV, IDIV Instructions….

Can not use those….

Immediate data

Page 20: 8086 Microprocesser Instructions

As Far our studies in i8086

Register The last 3 bits (m/r)

Accumulator Register (AX) 000

Count Register (CX) 001

Data register (DX) 010

Base Register (BX) 011

Stack pointer (SP) 100

Base pointer (BP) 101

Source Index (SI) 110

Destination index (DI) 111

Page 21: 8086 Microprocesser Instructions

Bibliography

• http://www.arl.wustl.edu/%7Elockwood/class/cs306/books/artofasm/toc.html

• Intel 8086 Microprocessor Datasheet• Richard C.Detmer, “Essentials of 80x86 Assembly

Language”.• Yu-Cheng Liu, Glenn A. Gibson, “Microcomputer

Systems : The 8086/8088 Family”

Page 22: 8086 Microprocesser Instructions

Thank you…..!!!!!