8086 Instruction Set Ppt 141126060207 Conversion Gate01

download 8086 Instruction Set Ppt 141126060207 Conversion Gate01

of 91

Transcript of 8086 Instruction Set Ppt 141126060207 Conversion Gate01

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    1/91

    1

    Instruction set ofInstruction set of

    8086 Microprocessor 8086 Microprocessor 

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    2/91

    2

    • The sequence of commands used to tell a microcomputer what todo is called a program,

    • Each command in a program is called an instruction• A program written in machine language is referred to as machine

    code

    ADD  AX, X

    !"pcode# !Destination operand# !$ource operand #

    $oftware$oftware

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    3/91

    3

    InstructionsInstructions

    %AE%& I'$T()*TI"' + *"MME'T

    Address identifier    Does not generate an machine code

    • Ex. START: MOV AX, BX  ; copy BX into AX

    • There is one!to!one re"tionship #et$een sse%#"y n&

    %chine "n'('e instr(ctions

    •  A co%pi"e& %chine co&e i%p"e%enttion o) pro'r%

    $ritten in hi'h!"e*e" "n'('e res("ts in ine))icient co&e

     + More %chine "n'('e instr(ctions thn n sse%#"e& *ersion o) n

    e(i*"ent hn&$ritten sse%#"y "n'('e pro'r%

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    4/91

    -

    • Two -e .enefits of assem.l language

    programming

     / It ta-es up less memor

     / It eecutes much faster 

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    5/91

    ApplicationsApplications

    • "ne of the most .eneficial uses ofassem.l language programming is

    real1time applications2

    (eal time means the tas- required . the

    application must .e completed .efore an other

    input to the program that will alter its operation can

    occur 

      3or eample the de4ice ser4ice routine which

    controls the operation of the flopp dis- dri4e is a

    good eample that is usuall written in assem.l

    language

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    6/91

    /

    • Assem.l language not onl good for

    controlling hardware de4ices .ut also

    performing pure software operations

     / $earching through a large ta.le of data for a special

    string of characters

     / *ode translation from A$*II to E*DI* / Ta.le sort routines

     / Mathematical routines

    Assem.l language& perform real1time operations

    5igh1le4el languages& used to write those parts

    that are not time critical

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    7/91

    0

    *on4erting Assem.l %anguage Instructions

    to Machine *ode• An instruction can .e coded with to 6 .tes• te contains three -inds of information

     / "pcode field !6 .its# specifies the operation !add, su.tract, mo4e#

     / (egister Direction it !D .it# Tells the register operand in (E7field in .te is source or destination operand

    & destination 0& source

    1 Data $i9e it !: .it# $pecifies whether the operation will .e

    performed on 81.it or 61.it data

     0& 8 .its & 6 .its

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    8/91

    • te has three fields

     / Mode field !M"D#

     / (egister field !(E7# used to identif the register for the first operand

     / (egister;memor field !(;M field#

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    9/91

    Mnemonic Meaning 3ormat "peration 3lags affected

    M"< Mo4e Mo4 D,$ !$# !D# 'one

    Data Transfer Instructions - MOVData Transfer Instructions - MOV

    Destination Source

    Memory Accumulator

    Accumulator Memory

    Register Register

    Register Memory

    Memory Register

    Register Immediate

    Memory Immediate

    Seg reg Reg 16

    Seg reg Mem 16

    Reg 16 Seg reg

    Memory Seg reg

    NO MOV

    Me%ory

    %%e&ite

    Se'%ent Re'ister 

    Me%ory

    Se'%ent Re'ister 

    Se'%ent Re'ister 

    EX: MOV A4, B4

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    10/91

    15

    Data Transfer Instructions - X!"Data Transfer Instructions - X!"

    Mnemonic Meaning 3ormat "peration 3lags affected

    X*57 Echange X*57 D,$ !$# !D# 'one

    Destination Source

    Accumulator Reg 16

    Memory Register

    Register Register

    Register Memory

    #$am%le& X!" START '(X)

    6O X789MEMs

    SE9 RE9s

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    11/91

    11

    Data Transfer Instructions * +#A, +DS, +#SMnemo

    nicMeaning 3ormat "peration 3lags

    affected

    %EA %oadEffecti4eAddress

    %EA (eg6,EA EA !(eg6# 'one

    %D$ %oad(egister

    And D$

    %D$ (eg6,MEM !MEM# !(eg6#

    !Mem=# !D$#

    'one

    %E$ %oad(egister

    and E$

    %E$ (eg6,MEM !MEM# !(eg6#

    !Mem=# !E$#

    'one

    +#A SI DATA  or. MOV SI Offset DATA

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    12/91

    12

    T/e X+AT InstructionT/e X+AT Instruction

    Mnemonic Meaning 3ormat "peration 3lags

    X%AT Translate X%AT !!A%#=!X#=!D$#0# !A%# 'one

    Example: 

    Assume (DS) = 0300H, (BX)=0100H, and (AL)=0DH

    XLAT replaces conens o! AL "# conens o! memor# loca$on %$& 

    'A=(DS)0 (BX) (AL)  = 03000H 0100H 0DH = 0310DH

    T&us

    (0310DH) (AL)

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    13/91

    13

    Arit/metic Instructions& ADD, AD, IN, AAA, DAA

    Mnemonic Meaning 3ormat "peration 3lags

    affected

    ADD Addition ADD D,$ !$#=!D# !D#

     carr !*3#

    A%%

    AD* Add withcarr

    AD* D,$ !$#=!D#=!*3# !D#

     carr !*3#

    A%%

    I'* Increment .one

    I'* D !D#= !D# A%% .ut *>

    AAA A$*II ad?ustfor addition

    AAA After addition AAA instruction isused to ma-e sure the result is the

    correct unpac-ed *D

    A3,*3

    DAA Decimalad?ust foraddition

    DAA Ad?ust A% for decimal@ac-ed *D

    A%%

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    14/91

    1-

    Eamples&

    E2  ADD AX,

    AD* AX,

    E2 I'* X

      I'* :"(D @T( XB

    E2C A$*II *"DE 01 C01Ch

     

    ADD *%,D% + *%BCA$*II 3"(

      + D%BCFA$*II 3"( F

    + (E$)%T*%B6G

    M"< A%,*% +Mo4e the ascii result into A% sinceAAA ad?ust onl A%B

      AAA +A%B0G, unpac-ed *D for G2

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    15/91

    1

    Arit/metic Instructions * S0(, S((, D#, AAS, DAS, N#"

    Mnemonic Meaning 3ormat "peration 3lagsaffected

    $) $u.tract $) D,$ !D# 1 !$# !D#

     orrow !*3#

    All

    $ $u.tractwith

    .orrow

    $ D,$ !D# 1 !$# 1 !*3# !D#

     

    All

    DE* Decrement. one

    DE* D   !D# 1 !D# All .ut *3

    'E7 'egate 'E7 D All

    DA$ Decimal

    ad?ust forsu.traction

    DA$ *on4ert the result in A% to

    pac-ed decimal format

    All

    AA$ A$*IIad?ust for

    su.traction

    AA$ !A%# difference

    !A5# dec . if .orrow

    *>,A*

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    16/91

    1/

    Multiplication and Di4ision

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    17/91

    10

    Multiplication and Di4ision

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    18/91

    1

    Multi%licationM0+ or IM0+.

    Multi%licand O%erandMulti%lier.

    Result

    (yte(yte A+ Register or memory AX

    2ord2ord AX Register or memory DX &AX

    D3ordD3ord #AX Register or memory #AX DX

    Di4ision

    DIV or IDIV.

    Di4idend O%erand

    Di4isor.

    5uotient& Remainder

    2ord(yte AX Register or Memory A+ & A!

    D3ord2ord DX&AX Register or Memory AX & DX

    53ordD3ord #DX& #AX Register or Memory #AX & #DX

    Multiplication and Di4ision

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    19/91

    1

    Multiplication and Di4ision Eamples

    #$1& Assume &a eac& $nsruc$on sars !rom &ese alues:

    AL = *+H, BL = 3+H, AH = 0H

    1 -.L BL / AL BL = *+H 3+H = 1B*H / AX = 1B*H

     

    2 -.L BL / AL BL = 24S AL BL = 24S (*+H) 3+H = 5BH 3+H = 155H/ 24s comp / E6*H / AX

    7 D8 BL /  = = 02 (*+9023+=1B) /

      D8 BL /  = =

    1B H 

     H 

    3+

    00*+

    02

     A8 A4

     BL

     AX 

     BL AX 

     H 

     H 

    3+00*+

    1B 02

     A8 A4

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    20/91

    25

    #$7& A+ 8 9:!, (+ 8 ;1!, A! 8 1 -.L BL / AL BL = ;3H 1H = *A3H / AX = *A3H

    2 -.L BL / AL BL = 24S AL  24S BL = 24S (;3H)  24S(1H) =

      0DH 6;H = 0+A3H / AX

     

    3D8 BL / = = = 2/ (00;3 < 26;=1+H) BL

     AX 

    )1(=2

    300

     H S 

     H  F 

     FH 

     H  F 

    6

    300

    AH AL

    1 52

      R 5

     NEG NEG

     POS = 2s ?E8

    AH AL

    1 ?E

     

    D8 BL / = = 01/(;3911=62) / BL AX 

     H  H  F 

    1300

    AH AL

    62  01

      R @

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    21/91

    21

    #$:& AX8 9

    DX AX

    013 B555

    2 -.L BX =  24S(;000H)  24S(01+H) = 1000 6;EB =

    DX AX

    5/?E B555

    3 D8 BL = = B6DH / -ore &an ;;H / D$$de Error  H 

     H  F 

    1+000

    D8 BL /  = = >3H ? 5; / D$$de Error  H 

     H  F S 

    1+

    )000(=2

     H 

     H 

    1+

    1000

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    22/91

    22

    #$>& AX8 17=

    1 D8 BL / = = = = = BL

     AX 

     H 

     H 

    0

    12+0

     NEG

     POS 

     sNEG

     POS 

    =2   )0(=2

    12+0

     H  s

     H 

     H 

     H 

    50

    12+0

      > 28 258125!255 >58  BL

     AX 

     H 

     H 

    0

    12+0 R @58 258  A8 A4

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    23/91

    23

    Mnemonic Meaning 9ormat O%eration 9lags Affected

    AND

    OR 

    XOR 

    NOT

    +ogical AND

    +ogical Inclusi4eOR 

    +ogical #$clusi4eOR 

    +O"IA+ NOT

    AND D,S

    OR D,S

    XOR D,S

    NOT D

    S. ? D. H D. 

    S.@D. H  D.

    S. D.HD.

     D. H D.

    O9, S9, B9, C9,

    9A9 undefined

    O9, S9, B9, C9,9

    A9 undefinedO9, S9, B9, C9,

    9A9 undefined

    None

    C

    %ogical Instructions

    Destination Source

    RegisterRegister

    MemoryRegister

    Memory

    Accumulator

    RegisterMemory

    RegisterImmediate

    Immediate

    Immediate

    DestinationRegister

    Memory

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    24/91

    2-

    %"7I*A% Instructions

    7 A@D

     < .ses an# address$n mode excep memor#9o9memor# andsemen re$sers

     < Espec$all# used $n clear$n cera$n "$s (mas$n)

      xxxx xxxx AND 0000 1111 = 0000 xxxx

    (clear &e !$rs !our "$s)

     < Examples: A@D BL, 0;H

    A@D AL, C3+H

    7 F 

     < .sed $n se$n cera$n "$sxxxx xxxx OR 0000 1111 = xxxx 1111

    (Se &e upper !our "$s)

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    25/91

    2

    7 XF  < .sed $n ner$n "$s

     xxxx xxxx XF 0000 1111 = xxxxx4x4x4x4

    -#$am%le& >lear "$s 0 and 1, se "$s 6 and 5, $ner "$ + o!re$ser >L:

    A@D >L, ;>H G 1111 1100B

    F >L, 0>0H G 1100 0000B

    XF >L, 020H G 0010 0000B

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    26/91

    2/

    $hift and (otate Instructions

     $5(;$A%& shift logical left;shiftarithmetic left

     $5(& shift logical right

     $A(& shift arithmetic right ("%& rotate left ("(& rotate right (*%& rotate left through carr

     (*(& rotate right through carr

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    27/91

    20

    4o'ic" *s Arith%etic Shi)ts

    •  A "o'ic" shi)t )i""s the ne$"y crete& #it position $ith Dero:

    7 An ar$&me$c s&$! !$lls &e ne%l# creaed "$

     pos$$on %$& a cop# o! &e num"er4s s$n "$:

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    28/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    29/91

    2

    Allowed operands

    Destination ount

    Register

    Register

     Memory Memory

    1

    +

    1

    +

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    30/91

    35

     

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    31/91

    31

    $5% Instruction

    • The S84

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    32/91

    32

    3ast Multiplication

     mov dl,5

    shl dl,1

    $hifting left .it multiplies a num.er .

     mov dl,5

    shl dl,2 ; DL = 20

    $hifting left n .its multiplies the operand .

    n

    ?or ex%p"e, 22 > 25

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    33/91

    33

    Ex.

    ; M("tip"y AX #y 15S84 AX, 1

    MOV BX, AX

    MOV 74,2

    S84 AX,74

     A AX, BX

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    34/91

    3-

    $5( Instruction

    • The S8R

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    35/91

    3

    $A( Instruction

    • $A( !shift arithmetic right# performs a rightarithmetic shift on the destination operand2

     An rith%etic shi)t preser*es the n(%#ers si'n.

     MOV DL,-80

    SAR DL,1 ; DL = -40

    SAR DL,2 ; DL = -10

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    36/91

    3/

    (otate Instructions(otate InstructionsMnem-onic

    Meaning 9ormat O%eration 9lags Affected

    RO+ Rotate+eft

    RO+ D,ount Rotate t/e D. left y t/enumer of it %ositions eEualto ountH #ac/ it s/ifted outfrom t/e left most it goes acinto t/e rig/tmost it %ositionH

    9O9 undefinedif count G 1

    ROR Rotate

    Rig/t

    ROR D,ount Rotate t/e D. rig/t y t/e

    numer of it %ositions eEualto ountH #ac/ it s/ifted outfrom t/e rig/tmost it goesac into t/e leftmost it%ositionH

    9

    O9 undefinedif count G 1

    R+ Rotate

    +eftt/roug/arry

    R+ D,ount Same as RO+ e$ce%t carry is

    attac/ed to D. for rotationH

    9

    O9 undefinedif count G 1

    RR Rotaterig/t

    t/roug/arry

    RR D,ount Same as ROR e$ce%t carry isattac/ed to D. for rotationH

    9O9 undefined

    if count G 1

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    37/91

    30

    ("% Instruction

    • ("% !rotate# shifts each .it to the left

    • The highest .it is copied into .oth the *arr flagand into the lowest .it

    • 'o .its are lost

     MOV Al,11110000b

    ROL Al,1 ; AL = 11100001b

     MOV Dl,3Fh

    ROL Dl,4 ; DL = F3h

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    38/91

    3

    ("( Instruction

    • ("( !rotate right# shifts each .it to the right

    • The lowest .it is copied into .oth the *arr flag andinto the highest .it

    • 'o .its are lost

     MOV AL,11110000b

    ROR AL,1 ; AL = 01111000b

     MOV DL,3Fh

    ROR DL,4 ; DL = F3h

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    39/91

    3

    (*% Instruction

    • (*% !rotate carr left# shifts each .it to the left

    • *opies the *arr flag to the least significant .it

    • *opies the most significant .it to the *arr flag

    CF

    CLC ; CF = 0

     MOV L,88H ; CF,L = 0 10001000b

    RCL L,1 ; CF,L = 1 00010000b

    RCL L,1 ; CF,L = 0 00100001b

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    40/91

    -5

    (*( Instruction

    • (*( !rotate carr right# shifts each .it to the right

    • *opies the *arr flag to the most significant .it

    • *opies the least significant .it to the *arr flag

    S!C ; CF = 1

     MOV AH,10H ; CF,AH = 00010000 1

    RCR AH,1 ; CF,AH = 10001000 0

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    41/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    42/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    43/91

    -3

    *ompare Instruction, *M@

    Mnemonic

    Meaning 3ormat "peration 3lagsAffected

    7MG 7o%pre 7MG ,S !D# / !$#  is (se& insettin' or resettin' the)"'s

    7?, A?, O?,G?, S?, H?

    !D# !$# + 30

    !D# J !$# + 30, *30

    !D# K !$# + 30, *3

    Allowed "perands

    Destination $ource

    (egister(egister 

    (egisterMemor

    Memor (egister  

    (egisterImmediate

    Memor Immediate

    Accumulator Immediate

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    44/91

    --

    $tringL

    • An arra of .tes or words located in

    memor

    • $upported $tring "perations

     + *op !mo4e, load#

     + $earch !scan#

     + $tore + *ompare

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    45/91

    -

    $tring Instruction asics

    • $ource D$&$I, Destination E$&DI

     + Io( %(st ens(re S n& ES re correct

     + Io( %(st ens(re S n& re o))sets into S n& ESrespecti*e"y

    • irection ?"' Jp, 1 > o$n=

     + 74 ! ncre%ent &&resses

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    46/91

    -/

    $tring Instructions$tring Instructions

    Instruction prefies

    @refi )sed with Meaning

    (E@

    (E@E;(E@

    (E@'E;(E@'

    M"

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    47/91

    -0

    InstructionsInstructions

    Mnemo1

    'ic

    meaning format "peration 3lags

    effect1ed

    MOVS Mo*e strin'

    S:SES:

    MOVSBKMOVSL

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    48/91

    -

    Mnemo1

    'ic

    meaning format "peration

    S7AS Scn strin'

     AX + ES:

    S7ASBK

    S7ASL

    Set )"'s s per 

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    49/91

    -

    ranch group of instructionsranch group of instructions

    ranch instructions pro4ide lot of con4enience to theprogrammer to perform operations selecti4el, repetiti4eletc2

    Brnch 'ro(p o) instr(ctions

    7on&ition" N(%ps

    Jncon&i!tion"

     N(%p

    tertioninstr(ctions

    7A44instr(ctions

    Ret(rninstr(ctions

    $)(")TI'E N $)(")TI'E 5A'DI%I'7 I'$T()*TI"'$

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    50/91

    5

    $)(")TI'E N $)(")TI'E 5A'DI%I'7 I'$T()*TI"'$

    *all su.routine A

    'et instruction

    *all su.routine A'et instruction

    Main program

    $u.routine A

    3irst Instruction

      (eturn

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    51/91

    1

     A s(#ro(tine is speci" se'%ent o) pro'r% tht cn #e c""e& )or

    exec(tion )ro% ny point in pro'r%.

     An sse%#"y "n'('e s(#ro(tine is "so re)erre& to s proce&(reP.

    Lhene*er $e nee& the s(#ro(tine, sin'"e instr(ction is inserte& in tothe %in #o&y o) the pro'r% to c"" s(#ro(tine.

    To #rnch s(#ro(tine the *"(e in the G or 7S n& G %(st #e

    %o&i)ie&.

     A)ter exec(tion, $e $nt to ret(rn the contro" to the instr(ction tht

    i%%e&ite"y )o""o$s the one c""e& the s(#ro(tine i.e., the ori'in"*"(e o) G or 7S n& G %(st #e preser*e&.

    Exec(tion o) the instr(ction c(ses the contents o) G to #e s*e& on

    the stcQ.

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    52/91

    2

    • Inter $egment

     + At starting *$ and I@ placed in a stac-2

     + 'ew 4alues are loaded in to *$ and I@ gi4en . theoperand2

     + After eecution original *$, I@ 4alues placed as it is2

    3ar1procMemptrC

    These two words !C .its# are loaded directl into I@ and

    *$ with eecution at *A%% instruction2

    3irst 6 I@

    'et 6 *$

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    53/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    54/91

    -

    (ET)('(ET)('

    • E*ery s(#ro(tine %(st en& #y exec(tin' n instr(ction tht ret(rns contro" to

    the %in pro'r%. This is the ret(rn

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    55/91

    %oop Instructions%oop Instructions

    • These instr(ctions re (se& to repet set o) instr(ctions se*er"

    ti%es.

    • ?or%t: 4OOG Short!4#e"

    • Opertion:

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    56/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    57/91

    0

    Mne%onic %enin' )or%t Opertion

    4OOG 4oop 4oop short!"#e" 5

    *ontrol flow and O)M@ instructions*ontrol flow and O)M@ instructions

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    58/91

    )nconditional Oump)nconditional Oump

      @art

      OM@ AA)nconditional OM@

    $-ipped part

      @art C

      AA XXXX

      @art

     

    'et instruction

    *ontrol flow and O)M@ instructions*ontrol flow and O)M@ instructions

    OM@ unconditional ?ump

    OM@ "perand

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    59/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    60/91

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    61/91

    /1

    *onditional Oump instructions*onditional Oump instructions

    *onditional Oump instructions in 8086 are ?ust .tes long2 1.teopcode followed . 1.te signed displacement !range of /8 to=G#2

    *onditional Oump Instructions

    Oumps .ased ona single flag

    Oumps .ased onmore than one flag

    *onditional Oump Instructions*onditional Oump Instructions

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    62/91

    /2

    *onditional Oump Instructions*onditional Oump Instructions

    Mnemonic &  Occ

    Meaning &  *onditional Oump

    3ormat &  Occ operand

    "peration &  If condition is true ?ump to the address specified . operand2

    "therwise the net instruction is eecuted2

    3lags affected &  'one

    T>@E$T>@E$

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    63/91

    /3

    Mnemonic meaning condition

    A A#o*e 7?>5 n& H?>5

    B A#o*e or E(" 7?>5

    B Be"o$ 7?>1

    BE Be"o$ or E(" 7?>1 or H?>1

    7 7rry 7?>1

    7XH 7X re'ister is Hero 5

    E E(" H?>1

    9 9reter H?>5 n& S?>O?

    9E 9reter or E(" S?>O?

    4 4ess 1

    Mnemonic meaning condition

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    64/91

    /-

    g

    4E 4ess or E(" 1 or H)>1

    6AE 6ot A#o*e nor E(" 7? > 1

    6B 6ot Be"o$ 7? > 5

    6BE 6ot Be"o$ nor E(" 7? > 5 n& H? > 5

    67 6ot 7rry 7? > 5

    6E 6ot E(" H? > 5

    69 6ot 9reter

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    65/91

    /

    Mnemonic meaning condition

    64E 6ot 4ess nor E(" H? > 5 n& S? > O?

    6O 6ot O*er)"o$ O? > 56G 6ot Grity G? > 5

    6H 6ot Hero H? > 5

    6S 6ot Si'n S? > 5

    O O*er)"o$ O? > 1

    G Grity G? > 1

    GE Grity E*en G? > 1

    GO Grity O&& G? > 5

    S Si'n S? > 1

    H Hero H? > 1

    Oumps ased on a single flagOumps ased on a single flag

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    66/91

    //

    Oumps ased on a single flagOumps ased on a single flag

    O r8 +Oump if 9ero flag set to !Oump if result is 9ero#

    O' r8 +Oump if 'ot ero ! flag 0 i2e2 result is non9ero#

    O$ r8 +Oump if $ign flag set to !result is negati4e#

    O'$ r8 +Oump if 'ot $ign !result is positi4e#

    O* r8 +Oump if *arr flag set to

    O'* r8 +Oump if 'o *arr

    O@ r8 +Oump if @arit flag set to !@arit is e4en#

    O'@ r8 +Oump if 'o @arit !@arit is odd#

    O" r8 +Oump if "4erflow flag set to !result is wrong#

    O'" r8 +Oump if 'o "4erflow !result is correct#

    There is no ?ump

    .ased on A* flag

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    67/91

    /0

    O r8 + OE !Oump if Equal# also means same2

    O' r8 + O'E !Oump if 'ot Equal# also means same2

    O* r8 +O !Oump if .elow# and O'AE !Oump if 'otA.o4e or Equal# also mean same2

    O'* r8 +OAE !Oump if A.o4e or Equal# and O' !Oump if'ot A.o4e# also mean same2

    O, O', O* and O'* used after arithmetic operation

    OE, O'E, O, O'AE, OAE and O' are used after acompare operation2

    O@ r8 + O@E !Oump if @arit E4en# also means same2

    O'@ r8 + O@" !Oump if @arit "dd# also means same2

    Eamples for OE or O instruction

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    68/91

    /

    Eamples for OE or O instruction

    Ex. for forward jump

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    69/91

    /

    Eamples for OE or O instruction

    Ex. for backward jump

    BA7U: SJB BX, AX ; exec(te& i) H > 1

    Sho("& #e

    > 12

    #ytes

    : =

    :

    7MG S,

    OE A*P

     A 7X, X ;exec(te& i) H > 5

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    70/91

    05

    Oumping .eond 18 to =GL

    Requirement Then do this!  

    7MG S, 7MG S,

    E SAME 6E 6EXT

    Lht i)

    120#ytes

     A 7X, X MG SAME

    : 6EXT: A 7X, X

    : :

    SAME: SJB BX, AX :

    SAME: SJB BX, AX

    Rn'e )or MG

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    71/91

    01

    Terms used in comparison

     A#o*e n& Be"o$ (se& )or co%prin' Jnsi'ne& nos.

    9reter thn n& "ess thn (se& $ith si'ne& n(%#ers.

     A"" nte" %icroprocessors (se this con*ention.

    8 is #o*e /8 Jnsi'ne& co%prison ! Tr(e

    8 is "ess thn /8 Si'ne& co%prison ! Tr(e

    8 is ne'ti*e, /8 is positi*e

    /8 is #e"o$ 8 Jnsi'ne& co%prison ! Tr(e

    /8 is 'reter thn 8 Si'ne& co%prison ! Tr(e

    Oump on multiple flagsOump on multiple flags

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    72/91

    02

    Oump on multiple flagsOump on multiple flags

    7on&ition" (%ps #se& on %ore thn one )"' re (se& )ter 7MG

    1 OR H> 1 7y > 5 A6 H > 5 7MG BX, 7X

    Be"o$ OR E(" S(re"y A#o*e BE BXWBE

    BXWBE

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    73/91

    03

    Oump on multiple flags contdOump on multiple flags contd..

    6BE or

    A

    (%p i) 6ot 5 A6 H> 5 7y > 1 OR H > 1 7MG BX, 7X

    S(re"y A#o*e Be"o$ OR E(" A BX#o*e

    BX#o*e

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    74/91

    0-

    Oump on multiple flags contdOump on multiple flags contd.

    4E or

    69

    (%p i) 4ess thn OR E("

    (%p i) 6ot 9reter thn

    Jump if o Jump if  

    S > 1 A6 V > 5

    1 OR H > 1

    S > 5 A6 V > 5

    5 A6 H > 5

    Oump on multiple flags contd2Oump on multiple flags contd2

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    75/91

    0

    Oump on multiple flags contd2Oump on multiple flags contd2

    64E or

    9

    (%p i) 6ot 1=

    5 1

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    76/91

    0/

    Oump on multiple flagsOump on multiple flags contd2contd2

    4 or69E

    (%p i) 4ess thn(%p i) 6ot 1

    Lhen S > 1, res("t cnnot #e 5

    S > 5 A6 V > 5

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    77/91

    00

    Oump on multiple flagsOump on multiple flags contd2contd2

    64 or9E

    (%p i) 6ot 4ess thn(%p i) 9reter thn OR E("

    Jump if o Jump if  

    S > 5 A6 V > 5

    1 A6 V > 5

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    78/91

    0

    'ear Oump'ear Oump

      6er (%p

    irect (%p

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    79/91

    0

    $hort Oump$ o t Ou p

    2 #yte

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    80/91

    5

    $hort Oump contd2p

    S8ORT Asse%#"er irecti*e

     Asse%#"er 'enertes on"y 2 #yte Short (%p co&e )or )or$r& N(%p, i) theS8ORT sse%#"er &irecti*e is (se&.

    MG $5"(T SAMEGro'r%%er sho("& ens(re tht the(%p &istnce is >120 #ytes

    :

    :

    SAME: MOV 7X, X

    %ong Oump%ong Oump

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    81/91

    1

    %ong Oump%ong Oump 

    3!#yte

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    82/91

    2

    %ong Oump contd2%ong Oump contd2

    t cn co*er entire /-U #ytes o) 7o&e se'%ent

    4on' (%p cnhn&"e it s N(%p

    (nt(% is>320/

    BUL > 7S:55558

    7S:5558 MG BUL

    :

    :

    7S:????8

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    83/91

    %ong Oump or $hort OumpL%ong Oump or $hort OumpL

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    84/91

    -

    g p pg p p

    7n #e trete&s s%""

    ??E58. Too

    *ery "on'

    #cQ$r& N(%p

    BUL> 7S:55158 :

    :MG BUL

    7S:???58

    7S:????8

    Intra segment indirect OumpIntra segment indirect Oump

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    85/91

    g pg p

    6er n&irect (%p is (nco%%on.nstr(ction "en'th: 2 or %ore #ytes

    Rn'e: co%p"ete se'%ent

    Ex.1:  MG X) X > 123-8, #rnches to 7S:123-8

    123-8 is not si'ne& re"ti*e &isp"ce%ent

    Ex. 2: MG $or&ptr 25558YBXZ

    BX 123-8 S:323-8 /08 Brnches to

    S:323/8 AB228 7S:/08

    3ar Oump3ar Oump

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    86/91

    /

    3ar Oump3ar Oump

      ?r (%p

    irect (%p

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    87/91

    0

    g pg p

    Also called 3ar Direct Oump

    It is the common inter segment ?ump scheme

    It is a F .te instruction

    .te opcode !EA5#

    .te offset 4alue .te segment 4alue

    E2 OM@ 3ar ptr %"*

    Inter segment Indirect OumpInter segment Indirect Oump

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    88/91

    Inter segment Indirect Oumpte seg e t d ect Ou p

    Instruction length depends on the wa ?ump location is

    specifiedIt can .e a minimum of .tes

    Ex. MG LOR GTR 25558YBXZ

    Inter segment Indirect OumpInter segment Indirect Oump

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    89/91

     A"so c""e& ?r n&irect (%pt is not co%%on"y (se&

    nstr(ction "en'th is %ini%(% o) 2 #ytes.

    t &epen&s on the $y N(%p "oction is speci)ie&

    Ex. MG LOR GTR 25558YBXZ

    BX 123-8 Brnches to

     AB78:/08

    S:323-8 /08 t is -!#yte instr(ctionS:323/8 AB78

    Machine control instructionsMachine control instructions

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    90/91

    5

    Machine control instructionsMachine control instructions

    5%T instr(ction + 8A4T processin'

    the 84T instr(ction $i"" c(se the 5/ to stop )etchin' n& exec(tin'instr(ctions. The 5/ $i"" enter h"t stte. The on"y $y to 'et the processoro(t o) the h"t stte re $ith n interr(pt si'n" on the 6TR pin or n interr(ptsi'n" on 6M pin or reset si'n" on the RESET inp(t.

    '"@ instr(ction

    this instr(ction si%p"y tQes (p three c"ocQ cyc"es n& &oes no

    processin'. A)ter this, it $i"" exec(te the next instr(ction. This instr(ction isnor%""y (se& to pro*i&e &e"ys in #et$een instr(ctions.

    E$* instr(ction

    $hene*er this instr(ction exec(tes, the %icroprocessor &oes 6OG orccess &t )ro% %e%ory )or coprocessor. This instr(ction psses thein)or%tion to 50 %th processor. Six #its o) ES7 instr(ction pro*i&e theopco&e to coprocessor.

    $hen 5/ )etches instr(ction #ytes, co!processor "so picQs (p these#ytes n& p(ts in its (e(e. The co!processor $i"" tret nor%" 5/instr(ctions s 6OG. ?"otin' point instr(ctions re exec(te& #y 50 n&&(rin' this 5/ $i"" #e in LAT.

    Machine control instructionsMachine control instructions contdcontd

  • 8/18/2019 8086 Instruction Set Ppt 141126060207 Conversion Gate01

    91/91

    %"*P instr(ction

    this is pre)ix to n instr(ction. This pre)ix %Qes s(re tht &(rin'exec(tion o) the instr(ction, contro" o) syste% #(s is not tQen #y other

    %icroprocessor.in %("tiprocessor syste%s, in&i*i&(" %icroprocessors re connecte&

    to'ether #y syste% #(s. This is to shre the co%%on reso(rces. Echprocessor $i"" tQe contro" o) this #(s on"y $hen it nee&s to (se co%%onreso(rce.

    the "ocQ pre)ix $i"" ens(re tht in the %i&&"e o) n instr(ction, syste%#(s is not tQen #y other processors. This is chie*e& #y hr&$re si'n"[4O7U *i"#"e on one o) the 7GJ pin. This si'n" $i"" #e %&e cti*e&(rin' this instr(ction n& it is (se& #y the #(s contro" "o'ic to pre*entothers )ro% tQin' the #(s.

    once this instr(ction is co%p"ete&, "ocQ si'n" #eco%es incti*e n&%icroprocessors cn tQe the syste% #(s.

    :AIT instr(ctionthis instr(ction tQes 5/ to n i&"e con&ition. The 7GJ $i"" not &o ny

    processin' &(rin' this. t $i"" contin(e to #e in i&"e stte (nti" TEST pin o)5/ #eco%es "o$ or n interr(pt si'n" is recei*e& on 6TR or 6M. On*"i& interr(pt SR is exec(te& n& processor enters the i&"e stte 'in