7/23/2019 Microprocessor 8086 MPA2 http://slidepdf.com/reader/full/microprocessor-8086-mpa2 1/96 Assembler & Microprocessor Emulator 1 8 86 Microprocessor 1. Assembler 2. Emulator • An Assembler program is used to translate the assembly language mnemonics for instructions to the corresponding binary codes. • On the first pass through the source program, the assembler determines the displacement of named data items, the offset of labels, etc. and puts this information in a symbol table. • On the second pass through the source program, the assembler produces the binary code for each instruction and inserts the offsets, etc., that it calculated during the first pass. • One such assembler is EMU8086- Assembler & Microprocessor Emulator 4.08 Dheeraj Suri
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
• Another way to run your program isthrough Emulator, such as EMU8086. An
Emulator is a mixture of hardware andSoftware.
• Hardware of Emulator is a multiwirecable which connects the host system tothe system being developed. A plug atthe end of the cable is plugged into the
prototype system in place of itsmicroprocessor. Through thisconnection the software of emulatorallows you to download your objectcode program into RAM in the systembeing tested and run it.
• Emulator allows you to run programs,
examine and change the contents ofregisters, examine and change thecontents of memory locations, andinsert breakpoints in the system.
Numerical data coming into computer froma terminal is usually in ASCII code.
In this code, the numbers 0 to 9 arerepresented by ASCII codes 30h to 39h.
The 8086 allows you to add the ASCII codes
for two decimal digits without masking offthe “3” in the upper nibble of each.After the addition, the AAA instruction isused to make sure the result is correctunpacked BCD.
Dheeraj Suri
ASCII stands for American Standard Code for Information Interchange.Computers can only understand numbers, so an ASCII code is the numerical
representation of a character such as 'a' or '@' or an action of some sort.
AAD converts two unpacked BCD digits inAH and AL to the equivalent binary number
in AL. The adjustment must be made beforedividing the two unpacked BCD digits in AXby an unpacked BCD byte. After thedivision, AL will contain the unpacked BCDquotient and AH will contain the unpacked
BCD remainder.Note: If an attempt is made to divide by 0,the 8086 will do a type 0 interrupt.
Before you can multiply two ASCII digits,you must first mask the upper 4 bits of
each. This leaves unpacked BCD (one BCDdigit per byte) in each byte. After twounpacked BCD digits are multiplied, theAAM instruction is used to adjust theproduct of two unpacked BCD digits in AX.
AAM instruction works only after themultiplication of two un-packed BCD bytes,and it works only on an operand in AL.
Dheeraj Suri
Flags affected : PF, SF, and ZF are updated. But AF, CF, and OF are left undefined.
Numerical data coming into a computerfrom a terminal is usually in ASCII code. In
this code the numbers 0 to 9 arerepresented by the ASCII codes 30H to 39H.The 8086 allows you to subtract the ASCIIcodes for two decimal digits withoutmasking the “3” in the upper nibble of each.
The AAS instruction is then used to makesure the result is the correct unpacked BCD.
Dheeraj Suri
Flags affected : AF and CF are updated, but OF, PF, SF and ZF are left undefined.
Flags affected : AF and CF are updated, but OF, PF, SF and ZF are left undefined.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
AF CF
SUB AL, BL ; Result: AL = 11111100 = -4
; in 2’s complement and CF = 1
AAS ; Result: AL = 00000100 =BCD04
; and CF = 1; borrow needed
The AAS instruction leaves the correctunpacked BCD result in the low nibble of AL
and resets the upper nibble of AL to all 0’s. Ifone wants to send the result back to a CRTterminal, one can OR AL with 30H to producethe correct ASCII code for the result. TheAAS instruction works only on the ALregister.
These instructions add a number from somesource to a number from some destination
and put the result in specified destination.The Add with Carry instruction, ADC, alsoadds the status of the carry flag into theresult. The source may be an immediatenumber, a register, or a memory location
specified by any one of the 24 addressingmodes. The destination may be a register ora memory location specified by any one ofthe 24 addressing modes. The source andthe destination in an instruction cannotboth be memory locations and they must be
PF = 0 Result has odd parity.AF = 1 Carry was produced out of bit 3.
ZF = 0 Result in destination was not 0.
SF = 1 Copies most significant bit of result;indicates negative result if you are
adding signed numbers
OF = 1 Set to indicate that the result ofaddition was too large to fit in thelower 7 bits of the destination used torepresent the magnitude of a signed
number. In other words, the resultwas greater than +127D, so the resultoverflowed into the sign bit positionand -
was negative. If you are adding twosigned 16-bit values, the OF will beset if the magnitude of the result istoo large to fit in the lower 15 bits ofthe destination.
NOTE: PF is meaningful only for an 8-bit result. AF is set only by a carry out of bit 3. Therefore,the DAA instruction cannot be used after wordadditions to convert the result to correct BCD.
This instruction ANDs each bit in a sourcebyte or word with the same number bit in a
destination byte or word. The result is putin the specified destination. The contents ofthe specified source will not be changed.The result for each bit position will followthe truth table for a two-input AND gate. In
other words, a bit in the specifieddestination will be a 1 only if that bit is a 1in both the source and the destinationoperands. Therefore, a bit can bemasked(reset) by ANDing it with 0.
Dheeraj Suri
Flags affected : PF, SF, and ZF are updated by AND. But CF and OF are both 0. AF isundefined.15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
The source operand can be an immediatenumber, the contents of a register, or the
contents of a memory location specified byone of the 24 addressing modes. Thedestination can be a register or a memorylocation. The source and the destinationcannot both be memory locations in thesame instruction. CF and OF are both 0 afterAND. PF, SF, and ZF are updated by AND. AFis undefined. Note that PF has meaning onlyfor an 8-bit operand.
Dheeraj Suri
Flags affected : PF, SF, and ZF are updated by AND. But CF and OF are both 0. AF isundefined.15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
The CALL instruction is used to transferexecution to a sub-program or procedure.
There are two basic types of calls, near andfar . A near call is a call to a procedurewhich is in the same code segment as theCALL instruction. When the 8086 executes anear CALL instruction, it decrements thestack pointer by 2 and copies the offset ofthe next instruction after the CALL onto thestack. This offset saved on the stack isreferred to as return address, because thisis the address that execution will return toafter the procedure executes. A near CALL
instruction will also load the instructionpointer with the offset of the firstinstruction in the procedure. A RETinstruction at the end of the procedure -
-- Will return execution of the instruction after the call bycopying the offset saved on the stack back to IP.
A far call is a call to a procedure which is in differentsegment from the one that contains the CALL instruction.When the 8086 executes a far call, it decrements thestack pointer by 2 and copies the contents of the CSregister to the stack. It then decrements the stack pointerby 2 again and copies the offset of the instruction afterthe CALL instruction to the stack. Finally it loads CS withthe segment base of the segment which contains theprocedure, and loads IP with the offset of the firstinstruction of the procedure in that segment. A RETinstruction at the end of the procedure will return
execution to the next instruction after the CALL byresorting the saved values of CS and IP from the stack.
CALL MULTO ; A direct within-segment (near or intra-
;segment) call. MULTO is the name of the;procedure. The assembler determines the;displacement of MULTO from the instruction;after the CALL and codes this displacement in;as part of the instruction.
Call BX ; An indirect within-segment near or intra-
segment
; call. BX contains the offset of the firstinstruction; of the procedure. Replaces the contents of IPwith contents of register BX.
CALL WORDPTR (BX)
; An indirect within-segment near or Intra-;segment call. Offset of first instruction of;procedure is in two memory addresses in DS.;Replaces contents IP with contents of word;memory location in DS pointed to by BX.
;intersegment call. SMART-DIVIDE is the name;of the procedure. The procedure must be;declared far with SMART_DIVIDE PROC FAR;at its start. The Assembler will determine the;code segment base for the segment which;contains the procedure and the offset of the
;start of the procedure. It will put these values;in as part of the instruction code.
CALLDWORDPTR[BX]
; An indirect call to another segment – far or;intersegment call. New Values for CS and IP;are fetched from four memory locations in DS.;The new value for CS is fetched from [BX] and;[BX+1]; the new IP is fetched from [BX+2];and [BX+3].
This instruction copies the sign of a byte inAL to all the bits in AH. AH is then said to be
the sign extension of AL. The CBW operationmust be done before a signed byte in AL canbe divided by another signed byte with theIDIV instruction. CBW affects no flags
This instruction resets the interrupt flag to0. No other flags are affected. If the
interrupt flag is reset, the 8086 will notrespond to an interrupt signal on its INTRinput. The CLI instruction, however, has noeffect on the non-maskable interrupt input,NMI.
If the Carry flag (CF) is a 0 before thisinstruction, it will be set to a 1 after the
instruction. If the carry flag is 1 before thisinstruction, it will be reset to 0 after theinstruction executes. Obviously CMC affectsonly the Carry Flag.Example:
Compares a byte/word from the specified sourcewith a byte/word from the specified destination.The source can be a an immediate number, aregister, or a memory location. The destinationcan be a register or a memory location. Thesource and destination cannot both be memorylocations in the same instruction. Thecomparison is actually done by subtracting the
source byte or word from the destination byte orword. The source and the destination are notchanged, but the flags are set to indicate theresults of comparison. AF, OF,SF, ZF, PF, and CFare updated by the CMP instruction.
Dheeraj Suri
Flags affected : AF, OF, SF, ZF, PF and CF are updated. Rest flags are unaffected.
The CMPS instruction can be used tocompare a byte/word in one string with a
byte/word in another string. SI is used tohold the offset of a byte or word in thesource string, and DI is used to hold theoffset of a byte or word in the other string.The comparison is done by subtracting thebyte or word pointed to by DI from the byteor word pointed to by SI. The AF, CF, OF, PF,SF and ZF flags are affected by thecomparison, but neither operand is affected.
---- contd.
Dheeraj Suri
Flags affected : AF,CF,OF,PF,SF and ZF are updated.
After the comparison, SI and DI willautomatically be incremented or decremented topoint to the next elements in the two strings. Ifthe direction flag has previously been set to a 1with an STD instruction, then SI and DI willautomatically be decremented by 1 for a bytestring or by 2 for word string. If the directionflag has been previously set to 0 with a CLDinstruction, SI and DI will automatically beincremented after the compare. They will beincremented by 1 for byte strings and by 2 for
word strings. The string pointed to by DI must
be in the extra segment, the string pointed to bySI must be in the data segment.
Dheeraj Suri
Flags affected : AF,CF,OF,PF,SF and ZF are updated.
-- NOTE:CX functions as a counter which the REPE prefixwill cause to be decremented after eachcompare. The B attached to the CMPS tells theassembler that the strings are of type byte. Ifyou want to tell the assembler that strings are oftype word, write the instruction as CMPSW. TheREPE CMPSW instruction will cause the pointersin SI and DI to be incremented by 2 after eachcompare if the direction flag is cleared ordecremented by 2 if the direction flag is set.
Dheeraj Suri
Flags affected : AF,CF,OF,PF,SF and ZF are updated.
CWD copies the sign bit of a word in AX toall the bits of the DX register. In other
words, it extends the sign of AX into all ofDX. The CWD operation must be donebefore a signed word in AX can be dividedby another signed word with the IDIVinstruction. CWD affects no flags.Example: --- contd.
This instruction is used to make sure theresult of adding two packed BCD numbers is
adjusted to be a legal BCD number. Theresult of addition must be in AL for DAA towork correctly. If the lower nibble in ALafter addition is greater than 9 or AF wasset by the addition, then the DAAinstruction will add 6 to the lower nibble inAL. If the result in the upper nibble is nowgreater than 9 or if the carry flag was set bythe addition or correction, then the DAAinstruction will add 60H to AL
Dheeraj Suri
Flags affected : DAA instruction updates AF, CF, PF, and ZF. OF is undefined afterthe DAA instruction.
This instruction is used after subtractingtwo packed BCD numbers to make sure the
result is correct packed BCD. The result ofsubtraction must be in AL for DAS to workcorrectly. If the lower nibble in AL aftersubtraction is greater than 9 or the AF wasset by the subtraction, then DAS wouldsubtract 6 from the lower nibble of AL.If the result in the upper nibble is nowgreater than 9 or if the carry flag was set,the DAS instruction will subtract 60 fromAL. Examples in the next slide.
Dheeraj Suri
Flags affected : DAS instruction updates AF, CF, SF, PF, and ZF. OF is undefinedafter the DAS instruction.
This instruction subtracts 1 from thedestination word or byte. The destinationcan be a register or a memory location
specified by any one of the 24 memoryaddressing modes. This instruction does notaffect the CF. That means if an 8-bitdestination containing 00h or a 16-bitdestination containing 0000h is
decremented, the result will be FFh orFFFFh with no carry (borrow).
Dheeraj Suri
Flags affected : AF, OF, PF, SF, and ZF are updated, but CF is not affected.
Flags affected : AF, OF, PF, SF, and ZF are updated, but CF is not affected.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF SF ZF AF PF
DEC CL ; Subtract 1 from contents of; CL register
DEC BP ; Subtract 1 from contents of BP; register
DEC BYTEPTR[BX]
; Subtract 1 from byte at offset[BX] in DS. The BYTE PTR directiveis necessary to tell the; assembler to put in the correct
; code for decrementing a byte in; memory, rather than; decrementing a word. The; instruction essentially says,; “Decrement the byte in memory; pointed to by the offset in BX”
Flags affected : AF, OF, PF, SF, and ZF are updated, but CF is not affected.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF SF ZF AF PF
DEC WORDPTR[BP]
;Subtract 1 from a word at offset; [BP] in SS. The WORD PTR
; directive tells the assembler to; put in the code for decrementing; a word pointed to by the; contents of BP. An offset in BP; will be added to the SS register; contents to produce the physical; address
DECTOMATO_CAN _COUNT
;Subtract 1 from byte or word; named TOMATO_CAN_COUNT inDS.
This instruction is used to divide an unsigned word bya byte or to divide an unsigned doubleword (32 bits)by a word.When a word is divided by a byte, the word must be inthe AX register. The divisor can be a register or in amemory location. After the division, AL will contain an8-bit result (quotient), and AH will contain a 8-bitremainder.When a double-word is divided by a word, theMSW(Most significant Word) of the doubleword must
be in DX, and the LSW of the doubleword must be inAX. After the result, AX will contain the 16-bitresult(quotient), and DX will contain 16-bit remainder.If one wants to divide a byte by a byte, one must firstput the dividend byte in AL and fill AH with all 0’s. TheSUB AH,AH instruction is a quick way to do this.
Dheeraj Suri
Flags affected : The CF, OF, SF, ZF, AF, and PF flags are undefined.
This instruction is used to pass instructions to aco-processor, such as the 8087 math processorwhich shares the address and data bus with
8086. Instructions for the co-processor arerepresented by a 6-bit code embedded in theescape instruction. As the 8086 fetchesinstruction bytes, the co-processor also catchesthese bytes from the data bus and puts them inits queue.
This instruction is used to divide a signed wordby a signed byte, or to divide a signeddoubleword (32bits) by a signed word.
When dividing a signed word by a signed byte,the world must be in the AX register. The divisorcan be in an 8-bit register or a memory location.After the division, AL will contain the signedresult (quotient), and AH will contain the signedremainder. The sign of the remainder will be the
same as the sign of the dividend. If an attempt ismade to divide by 0, the quotient is greater than127 (7Fh), or the quotient is less than -127(81h), the 8086 will automatically do a type 0interrupt.If one wants to divide a signed byte by a signed
byte, one must first put the dividend byte in ALand fill AH with copies of the sign bit from AL. Inother words, if AL is +ve, then AH should befilled with all 0’s . If AL is –ve (sign bit = 1)..
--- then AH should be filled with all 1’s. The8086 convert byte to world instruction, CBW,does this by copying the sign bit of AL to all bits
of AH. AH is then said to contain the “signextension of AL”.Likewise, if one wants to divide a signed word bya signed word, one must put the dividend wordin AX and extend the sign of AX to all bits of DX.The 8086 Convert Word to Double word
instruction, CWD, will copy the sign bit of AX toall bits of DX.
Dheeraj Suri
Flags affected : All flags are undefined after a IDIV.
Note: Although the quotient is actually closer to 13 (12.66667) than to12, the 8086 truncates it to 12 rather than rounding it to 13. If you wantto round the quotient, you can compare the magnitude of the remainderwith (divisor/2) and add 1 to the quotient if the remainder is greater
than (divisor/2). Note that the sign of the remainder is the same as the sign of the dividend (negative).
Dheeraj Suri
Flags affected : All flags are undefined after a IDIV.
This instruction multiplies a signed byte from some source times asigned byte in AL or a signed word from some source times a signed wordin AX. The source can be another register or a memory location specifiedby any one of the 24 addressing modes (memory addressing). When abyte from some source is multiplied by AL, the signed result will be put in
AX. A 16-bit destination is required because the result of multiplying two8-bit numbers can be as large as 16-bits. When a word from some sourceis multiplied by AX, the result can be as large as 32 bits. The higher orderword of signed result is put in DX, and lower order word is put in AX. Ifthe magnitude of the product doesn’t require all bits of destination, theunused bits will be filled with copies of sign bit. If the upper byte of a 16-bit result or the upper word of a 32-bit result contains only copies of thesign bit (all 0’s or all 1’s ) , then CF and OF will be both 0. if the upperbyte of a 16-bit result or the upper word of a 32-bit result contains part
of the product, CF and OF will both be 1. One can use the status of theflags to determine whether upper byte or word of the product needs to bekept. One can use the status of these flags to determine whether upperbyte or word of the product needs to be kept.If one wants to multiply a signed byte by a signed word, one must firstmove the byte into a word location and fill the upper byte of the word
with copies of the sign bit. If one moves the byte into AL, one can use the8086 convert byte to word instruction, CBW, to do this.
Dheeraj Suri
Flags affected : CF and OF are updated. AF, PF, SF and ZF are undefined after IMUL
The IN instruction will copy data from a port to the ALor AX register. If an 8-bit port is read, the data will goto AL. If a 16-bit port is read, the data will go to AX.The IN instruction has two possible formats, fixed port
and variable port.For the fixed port type, the 8-bit address of a port isspecified directly in the instruction. Examples:
Dheeraj Suri
Flags affected : The IN instruction do not change any flags.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IN AL, 0C8h ;Input a byte from port 0C8h to; AL
IN AX, 34h ; Input a word from port 34h to AXA_TO_D EQU4Ah
For the variable-port-type IN instruction, the portaddress is loaded into the DX register before the INinstruction. Since DX is a 16-bit register, the portaddress can be any number between 0000h and FFFFh.
Therefore, up to 65,536 ports are addressable in thismode. Examples:
Dheeraj Suri
Flags affected : The IN instruction do not change any flags.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MOV DX,0FF78h
; Initialize DX to point to port
IN AL, DX ; Input a byte from 8-bit port
; 0FF78h to AL
IN AX, DX ; Input a word from 16-bit port; 0FF78h to AX
The INC instruction adds 1 to a specifiedregister or to a memory location specified inany one of the 24 addressing modes
(memory). Examples:
Note: Carry flag is not affected. This means that if an 8-bit destination containing FFh ora 16-bit destination containing FFFFh is incremented, the result will be all 0’s with noCarry
Dheeraj Suri
Flags affected : AF, OF, PF, SF, and ZF are affected. CF is not affected.
4. Get a new value for IP from an absolutememory address of 4 times the typespecified in the instruction.
5. Get a new value for CS from an absolutememory address of 4 times the typespecified in the instruction plus 2.6. Reset both IF and TF. Other flags are notaffected. Examples:
Dheeraj Suri
Flags affected : IF and TF are affected. Other flags are not affected.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IF TF
INT 35 ; New IP from 0008Ch, new CS from0008Eh
INT 3 ; This is a special form which hasthe single-byte code of CCh. Manysystems use this as a break-pointinstruction. New IP from 0000Ch,new CS from 0000Eh
If the overflow flag (OF) is set, this instruction willcause the 8086 to do an indirect far call to a procedureyou write to handle the overflow condition. Beforedoing the call, the 8086 will:
1. Decrement the stack pointer by 2 and push theflags onto stack.
2. Decrement the stack pointer, by 2 and push CSonto the stack.
3. Decrement the SP by 2 and push the offset of thenext instruction after the INTO instruction onto the
stack.4. Reset TF and IF. Other flags are not affected. Todo the call, the 8086 will read a new value for IPfrom address 00010h and a new value of CS fromaddress 00012h.
When the 8086 responds to an interrupt signalor to an interrupt instruction, it pushes the flags,the current value of CS, and the current value of
IP onto the stack. It then loads CS and IP withthe starting address of the procedure which onewrites for the response to that interrupt. TheIRET instruction is used at the end of theinterrupt service procedure to return executionto the interrupted program. To do this return,
the 8086 copies the saved value of IP from thestack to IP, the stored value of CS from the stackto CS, and the stored value of the flags back tothe flag register. Flags will have the values theyhad before the interrupt, so any flag settingsfrom the procedure will be lost unless they are
specifically saved in some way.
Note: The RET instruction should not normally be used to return from interrupt procedures because it doesnot copy the flags from the stack back to the flagregister.
The three mnemonics represent the sameinstruction. The terms above and below are usedwhen referring to the magnitude of unsigned
numbers. The number 0111 is above the number0010. If, after a compare or some otherinstruction which affects flags, the carry flag is0, this instruction will cause execution to jumpto a label given in the instruction. If CF is 1, theinstruction will have no effect on the program
execution. The destination label for the jumpmust be in the range of -128 bytes to +127 bytesfrom the address of the instruction after the JAE.JAE/JNB/JNC affects no flags.
JBE & JNA represent the same instruction. Theterms above and equal are used when referringto the magnitude of unsigned numbers. The
number 0111 is above the number 0010. If, aftera compare or some other instruction whichaffects flags, either the zero flag or the carry flagis 1, this instruction will cause execution to jumpto a label given in the instruction. If CF and ZFare both 0, the instruction will have no effect on
program execution. The destination label for the jump must be in the range of -128 bytes to +127bytes from the address of the instruction afterthe JBE. JBE/JNA affects no flags.
This instruction will cause a jump to a label given inthe instruction if the CX register contains all 0’s,execution will simply proceed to the next instruction.Note that this instruction doesnot look at the zero flag
when it decides whether to jump or not. Thedestination label for this instruction must be in therange of -128 to +127 bytes from the address of theinstruction after JCXZ instruction. JCXZ affects noflags. Example:
JE & JZ mnemonics represent the sameinstruction. If the zero flag is set, this instructionwill cause execution to jump to a label given in
the instruction. If the zero flag is not 1,execution will simply go on to the nextinstruction after JE or JZ. The destination labelfor the JE/JZ instruction must be in the range of-128 to +127 bytes from the address of theinstruction after the JE/JZ instruction. JE/JZ
JG or JNLE represent the same instruction. Theterms greater or less are used to refer to therelationship of two signed numbers. Greater
means more positive. The number 00000111 isgreater than the number 11101010, because insigned notation the second number is negative.This instruction is usually used after a Compareinstruction. The instruction will cause a jump toa label given in the instruction if the Zero Flag is
0 and the carry flag is the same as the overflowflag. The destination label must be in the rangeof -128 bytes to +127 bytes from the address of instruction after JG/JNLE instruction. If the jumpis not taken, execution simply goes on to thenext instruction after the JG or JNLE instruction.
JGE/JNL both represent the same instruction. Theterms greater and less are used to refer to therelationship of two signed numbers. Greater meansmore positive. The number 00000111 is greater
than the number 11101010, because in signednotation the second number is negative. Thisinstruction is usually used after the compareinstruction. The instruction will cause a jump to alabel given in the instruction if the sign flag is equalto the overflow flag. The destination label must be
in the range of -128 bytes to +127 bytes from theaddress of the instruction after the JGE/JNLinstruction. If the jump is not taken, executionsimply goes on to the next instruction after the JGEor JNL instruction. JGE/JNL affects no flags.Example (on next slide)
JL/JNGE both represent the same instruction. Theterms greater and less are used to refer to therelationship of two signed numbers. Greater meansmore positive. The number 00000111 is greater
than the number 11101010, because in signednotation the second number is negative. Thisinstruction is usually used after the compareinstruction. The instruction will cause a jump to alabel given in the instruction if the sign flag is notequal to the overflow flag. The destination label
must be in the range of -128 bytes to +127 bytesfrom the address of the instruction after theJL/JNGE instruction. If the jump is not taken,execution simply goes on to the next instructionafter the JL or JNGE instruction. JL/JNGE affects noflags. Example (on next slide)
JLE/JNG both represent the same instruction. Theterms greater and less are used to refer to therelationship of two signed numbers. Greater meansmore positive. The number 00000111 is greater
than the number 11101010, because in signednotation the second number is negative. Thisinstruction is usually used after the compareinstruction. The instruction will cause a jump to alabel given in the instruction if the zero flag is set,or if the sign flag is not equal to the overflow flag.
The destination label must be in the range of -128bytes to +127 bytes from the address of theinstruction after the JLE/JNG instruction. If the jump is not taken, execution simply goes on to thenext instruction after the JL or JNGE instruction.JLE/JNG affects no flags. Example (on next slide)
Will always cause the 8086 to fetch the nextinstruction from the location specified in theinstruction rather than from the next location
after the JMP instruction. If the destination is inthe same code segment as the JMP instruction,then only the instruction pointer will be changedto get to the destination location (near jump). Ifthe destination for the jump instruction is in asegment with a name different from that of the
segment containing the JMP instruction, thenboth the IP and CS segment register contentswill be changed to get to the destination location(far jump). The JMP instruction affects no flags.Examples: (next slide)
Dheeraj Suri
Flags affected : No flags are affected after JMP instruction.
Flags affected : No flags are affected after JMP instruction.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
JMP Continue ; Fetch next instruction fromaddress at label CONTINUE
JMP BX ; Replace the contents of IPwith; the contents of BX. BX mustfirst be loaded with the offsetof the destination instructionin CS. This is a near jump. It is
also referred to as an indirect jump because the new valuefor IP comes from a registerrather than from theinstruction itself, as in a direct