Inst_of_8086

Embed Size (px)

Citation preview

  • 8/8/2019 Inst_of_8086

    1/11

    Flag Registers

    Flag register contains information reflecting the current status of microprocessor. Italso contains information which controls the operation of the microprocessor.

  • 8/8/2019 Inst_of_8086

    2/11

    Test for Sign Flags , OV Flag for the following syntax:mov al, ff , mov ax, ff, mov ax, ffff

  • 8/8/2019 Inst_of_8086

    3/11

    Flag Control Instruction : Bit Positions

    ex: LAHF and SAHF

    -read or change flags.-data transfer must be between AH register and the flagregister- Other instruction to clear or reset Carry and interrupt flags.

    ExampleExample:Write an instruction sequence to save the current contents of the 8088s flags in thememory location at offset MEM1 of the current data segment and then reload the

    flags with the contents of the storage location at offset MEM2.

    Solution:LAHF ; Read from Flag to AHMOV [MEM1], AH ; Copy to Memory 1MOV AH, [MEM2] ; Copy from MEM1 to AHSAHF ; Set the flags from AH

    Compare Instructions

  • 8/8/2019 Inst_of_8086

    4/11

    TO DETERMINE THE RELATIONSHIP BETWEEN TWO NUMBERS

    :- equal, larger or smallerSubtraction operationThe result is not savedBased on the result, appropriate flag are set or reset.Examples:Given a sequence of number, find a minumum numberMOV AL, 7CMP AL, 5MOV AL, 99H; -103CMP AL, 1BH; +27Compares the destination operand to the source operand. Destination operand is

    not changes

    CMP D,SExample 1:MOV AL,5

    CMP AL,5 ;Zero flag is set

    Example 2:MOV AL,4

    CMP AL,5 ;Carry flag is set

    Example:Describe what happens to the status flags as the sequence of instructionsthat follows is executed.All flags initially reset.MOV AX,1234H

    MOV BX.ABCDH

    CMP AX,BX

  • 8/8/2019 Inst_of_8086

    5/11

    CONTROL FLOW AND THE JUMP INSTRUCTIONS

    Control flow relates to altering the execution path of instructions in aprogram.It may cause a sequence of instructions to be repeated or a group of

    instructions to not be executed at all.For a change in the control flow, we have to change the contents of thecode segment register and instruction pointer.

    So, to control the flow of a program, we usejump instruction A jump may be conditional or unconditional Common conditional jumps are related to the conditions of flags such asCARRY, OVERFLOW, SIGN OR ZERO.When a jump is executed the program is sent to a new location by loading theprogram counter (CS:IP) with a new value .

    If the branch address is in the same CS memory then the jump is called as anIntrasegment jump. If the branch address is in different CS memory then the jump is called anIntersegment jump.

  • 8/8/2019 Inst_of_8086

    6/11

    As the instruction is executed, the jump always take place to change theexecution sequence.- No status requirement for the jump to occur

    Jump Instructions

  • 8/8/2019 Inst_of_8086

    7/11

    UNCONDITIONAL JUMP

    It moves microprocessor to execute another part of the program Target can be represented by a label, immediate data, registers, ormemory locations

    It does not affect flagsAssembly language couldnt exist without unconditional jumps.

  • 8/8/2019 Inst_of_8086

    8/11

    Intrasegment transfer v.s. Intersegment transfer

    Intrasegment transfer: the microprocessor jumps to an address withinthe same segment we can provide only new IP value in JMP instructions.For Example: JMP 1000H Intersegment transfer: the microprocessor jumps to an address in adifference segmentwe need to provide both new CS and IP values in JMP instructions

    For Example: JMP 2000H : 1000H

    Direct Jump v.s. Indirect Jump

    Direct Jump: the target address is directly given in the instruction Indirect Jump: the target address is contained in a register or memorylocation

    Loop instruction

    LOOP= when a group of instructions may need to be executed over and

  • 8/8/2019 Inst_of_8086

    9/11

    over again until a condition is metThe loop program structure is to implement- REPEAT-UNTIL and WHILE-DO

  • 8/8/2019 Inst_of_8086

    10/11

  • 8/8/2019 Inst_of_8086

    11/11