ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Assembly Language Assembly Instruction Set ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Overview Overview of the Instruction Format º º AAA ASCII Adjust after Addition º º AAD ASCII Adjust before Division º º AAM ASCII Adjust after Multiply º º AAS ASCII Adjust after Subtraction º º ADC Add with Carry º º ADD Addition º º AND Logical AND º º CALL Call Procedure º º CBW Convert Byte to Word º º CLC Clear Carry Flag º º CLD Clear Direction Flag º º CLI Clear Interrupt-Enable Flag º º CMC Complement Carry Flag º º CMP Compare º º CMPS Compare String (Byte or Word) º º CMPSB Compare String Byte º º CMPSW Compare String Word º º CWD Convert Word to Doubleword º º DAA Decimal Adjust after Addition º º DAS Decimal Adjust after Subtraction º º DEC Decrement º º DIV Divide, Unsigned º º ESC Escape º º HLT Halt º º IDIV Integer Divide, Signed º º IMUL Integer Multiply, Signed º º IN Input Byte or Word º º INC Increment º º INT Interrupt º º INTO Interrupt on Overflow º º IRET Interrupt Return º º JA Jump If Above º º JAE Jump If Above or Equal º º JB Jump If Below º º JBE Jump If Below or Equal º º JC Jump If Carry º º JCXZ Jump if CX Register Zero º º JE Jump If Equal º º JG Jump If Greater º º JGE Jump If Greater or Equal º º JL Jump If Less º º JLE Jump If Less or Equal º º JMP Jump Unconditionally º º JNA Jump If Not Above º º JNAE Jump If Not Above or Equal º º JNB Jump If Not Below º º JNBE Jump If Not Below or Equal º º JNC Jump If No Carry º º JNE Jump If Not Equal º º JNG Jump If Not Greater º º JNGE Jump If Not Greater or Equal º º JNL Jump If Not Less º º JNLE Jump If NOt Less or Equal º º JNO Jump If No Overflow º º JNP Jump If No Parity º º JNS Jump If No Sign º º JNZ Jump If Not Zero º º JO Jump If Overflow º º JP Jump If Parity º º JPE Jump If Parity Even º º JPO Jump If Parity Odd º º JS Jump If Sign º º JZ Jump If Zero º º LAHF Load Register AH from º º LDS Load Pointer Using DS º º LEA Load Effective Address º º LES Load Pointer Using ES º º LOCK Lock the Bus º º LODS Load String (Byte or Word) º º LODSB Load String Byte º º LODSW Load String Word º º LOOP Loop on Count º º LOOPE Loop While Equal º º LOOPNE Loop While Not Equal º º LOOPNZ Loop While Not Zero º º LOOPZ Loop While Zero º º MOV Move (Byte or Word) º º MOVS Move String (Byte or Word) º º MOVSB Move String Byte º º MOVSW Move String Word º º MUL Multiply, Unsigned º º NEG Negate º º NOP No Operation º º NOT Logical NOT º º OR Logical OR º º OUT Output to Port º º POP Pop a Word from the Stack º º POPF Pop Flags from the Stack º º PUSH Push Word onto Stack º º PUSHF Push Flags onto Stack º º RCL Rotate through Carry Left º º RCR Rotate through Carry Right º º REP Repeat º º REPE Repeat While Equal º º REPNE Repeat While Not Equal º º REPNZ Repeat While Not Zero º º REPZ Repeat While Zero º º RET Return from Procedure º º ROL Rotate Left º º ROR Rotate Right º º SAHF Store Register AH into º º SAL Shift Arithmetic Left º º SAR Shift Arithmetic Right º º SBB Subtract with Borrow º º SCAS Scan String (Byte or Word) º º SCASB Scan String Byte º º SCASW Scan String Word º º SHL Shift Logical Left º º SHR Shift Logical Right º º STC Set Carry Flag º º STD Set Direction Flag º º STI Set Interrupt Enable Flag º º STOS Store String (Byte or Word) º º STOSB Store String Byte º º STOSW Store String Word º º SUB Subtract º º TEST Test º º WAIT Wait º º XCHG Exchange Registers º º XLAT Translate º º XOR Exclusive OR º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ºOverview Overview of the Instruction Format º º Each entry in this list includes information on which flags in the º 8088's flag register are changed, and how they're changed. Since º there are 9 flags in the flags register, the flags display is very º compact: º Flags: O D I T S Z A P C º 0 * * ? * 0 º º ? Undefined after the operation. º * Changed to reflect the results of the instruction. º 0 Always cleared º 1 Always set º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The timing charts show timings for the 8088. Since the 80x8x º processors execute instructions in fewer clock cycles than the 8088, º these charts represent the worst case. ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands This field gives the list of possible operands and º addressing modes for each instruction. º º Clocks Number of clock cycles required to execute the º instruction on an 8088. Effective Address º calculations (EA) take additional time, as outlined º in the EA table. º º Transfers The number of memory references. 4 clock cycles are º required for each memory reference. º º Bytes Number of bytes in the instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: The additional clock cycles required to reinitialize º the instruction que and fetch the next instruction º after a control transfer instruction (such as JMP or º CALL) is already included in the timing tables. Two º clock times are listed for conditional transfer º instructions (such as JZ); the shortest time is for º the case when there is no transfer. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: AAD AAS AAM ADC DAA Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºAAA ASCII Adjust after Addition Flags: O D I T S Z A P C º ? ? ? * ? * ºAAA º Logic: If (AL & 0Fh) > 9 or (AF = 1) then º AL <- AL + 6 º AH <- AH + 1 º AF <- 1; CF <- 1 º else º AF <- 0; CF <- 0 º AL <- AL & 0Fh º º Converts the number in the lower 4 bits (nibble) of AL to an unpacked º BCD number (high-order nibble of AL is zeroed). º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 4 - 1 AAA º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º If the lower 4 bits of the number in AL is greater than 9, or the º auxiliary carry flag is set, this instruction converts AL to its º unpacked BCD form by adding 6 (subtracting 10) to AL; adding 1 to AH; º and setting the auxiliary flag and carry flags. This instruction will º always leave 0 in the upper nibble of AL. º º Note: Unpacked BCD stores one digit per byte; AH contains º the most-significant digit and AL the least- º significant digit. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: AAA AAS AAM DIV IDIV Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºAAD ASCII Adjust before Division Flags: O D I T S Z A P C º ? * * ? * ? ºAAD º Logic: AL <- AH * 10 + AL º AH <- 0 º º AAD converts the unpacked two-digit BCD number in AX into binary in º preparation for a division using DIV or IDIV, which require binary º rather than BCD numbers. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 60 - 2 AAD º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º AAD modifies the numerator in AL so that the result produced by a º division will be a valid unpacked BCD number. For the subsequent DIV º to produce the correct result, AH must be 0. After the division, the º quotient is returned in AL, and the remainder in AH. Both high-order º nibbles are zeroed. º º Note: Unpacked BCD stores one digit per byte; AH contains º the most-significant digit and AL the least- º significant digit. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: AAA AAD AAS MUL IMUL Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºAAM ASCII Adjust after Multiply Flags: O D I T S Z A P C º ? * * ? * ? ºAAM º Logic: AH <- AL / 10 º AL <- AL MOD 10 º º This instruction corrects the result of a previous multiplication of º two valid unpacked BCD operands. A valid 2-digit unpacked BCD number º is taken from AX, the adjustment is performed, and the result is º returned to AX. The high-order nibbles of the operands that were º multiplied must have been 0 for this instruction to produce a correct º result. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 83 - 1 AAM º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: Unpacked BCD stores one digit per byte; AH contains º the most-significant digit and AL the least- º significant digit. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: AAA AAD AAS SUB SBB DAS Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºAAS ASCII Adjust after Subtraction Flags: O D I T S Z A P C º ? ? ? * ? * ºAAS º Logic: If (AL & 0Fh) > 9 or AF = 1 then º AL <- AL - 6 º AH <- AH - 1 º AF <- 1; CF <- 1 º else º AF <- 0; CF <- 0 º AL <- AL & 0Fh º º AAS corrects the result of a previous subtraction of two valid º unpacked BCD operands, changing the content of AL to a valid BCD º number. The destination operand of the subtraction must have been º specified as AL. The high-order nibble of AL is always set to 0. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 4 - 1 AAS º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: Unpacked BCD stores one digit per byte; AH contains º the most-significant digit and AL the least- º significant digit. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: ADD INC AAA DAA EA Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºADC Add with Carry Flags: O D I T S Z A P C º * * * * * * ºADC destination,source º Logic: destination <- destination + source + CF º º ADC adds the operands, adds 1 if the Carry Flag is set, and places the º resulting sum in destination. Both operands may be bytes or words, and º both may be signed or unsigned binary numbers. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 3 - 2 ADC BX,SI º register, immediate 4 - 3-4 ADC CX,128 º accumulator, immediate 4 - 2-3 ADC AL,10 º register, memory 9(13) + EA 1 2-4 ADC DX,RESULT º memory, register 16(24) + EA 2 2-4 ADC BETA,DI º memory, immediate 17(25) + EA 2 3-6 ADC GAMMA,16h º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: ADC is useful for adding numbers that are larger º than 16 bits, since it adds a carry from a previous º operation. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: ADC INC AAA DAA EA Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºADD Addition Flags: O D I T S Z A P C º * * * * * * ºADD destination,source º Logic: destination <- destination + source º º ADD sums the operands and stores the result in destination. Both º operands may be bytes or words, and both may be signed or unsigned º binary numbers. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º Byte(word) º register, register 3 - 2 ADD BX,CX º accumulator, immediate 4 - 2-3 ADD AX,256 º register, immediate 4 - 3-4 ADD BL,4 º register, memory 9(13) + EA 1 2-4 ADD DI,[DX] º memory, register 16(24) + EA 2 2-4 ADD TOTAL,BL º memory, immediate 17(25) + EA 2 3-6 ADD RESULT,3 ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: NOT OR XOR EA Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºAND Logical AND Flags: O D I T S Z A P C º 0 * * ? * 0 ºAND destination,source º º Logic: destination <- destination AND source º º AND performs a bit-by-bit logical AND operation on its operands and º stores the result in destination. The operands may be words or bytes. º º AND Instruction Logic º Destination Source Result º 0 0 0 º 0 1 0 º 1 0 0 º 1 1 1 º º AND sets each bit of the result to 1 if both of the corresponding bits º of the operands are 1. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 3 - 2 AND AL,DL º register, immediate 4 - 3-4 AND CX,0FFh º accumulator, immediate 4 - 2-3 AND AX,01000010b º register, memory 9(13) + EA 1 2-4 AND CX,MASK º memory, register 16(24) + EA 2 2-4 AND VALUE,BL º memory, immediate 17(25) + EA 2 3-6 AND STATUS,01h ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: RET JMP PROC NEAR FAR EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºCALL Call Procedure Flags: not altered º ºCALL procedure_name º º Logic: if FAR CALL (inter-segment) º PUSH CS º CS <- dest_seg º PUSH IP º IP <- dest_offset º º CALL transfers control to a procedure that can either be within the º current segment (a NEAR procedure) or outside it (a FAR procedure). º The two types of CALLs result in different machine instructions, and º the RET instruction that exits from the procedure must match the type º of the CALL instruction (the potential for mismatch exists if the º procedure and the CALL are assembled separately). º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º near-proc 19(23) 1 3 CALL NEAR_PROC º far-proc 28(36) 2 5 CALL FAR_PROC º memptr 16 21(29) + EA 2 2-4 CALL PROC_TABLE[SI] º regptr 16 16(24) 1 2 CALL AX º memptr 32 37(57) + EA 4 2-4 CALL [BX].ROUTINE º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: For an inter-segment procedure (procedure in a º different segment), the processor first pushes the º current value of CS onto the stack, then pushes the º current value of IP (which is pointing to the º instruction following the CALL instruction), then º transfers control to the procedure. º For an intra-segment procedure (procedure in the º same segment), the processor first pushes the º current value of IP (which is pointing to the º instruction following the CALL instruction) onto the º stack, then transfers control to the procedure. º CALL can also read the procedure address from a º register or memory location. This form of CALL is º called an indirect CALL. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: CWD DIV IDIV ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºCBW Convert Byte to Word Flags: not altered º ºCBW º Logic: if (AL < 80h) then º AH <- 0 º else º AH <- FFh º º CBW extends the sign bit of the AL register into the AH register. This º instruction extends a signed byte value into the equivalent signed º word value. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 2 - 1 CBW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: This instruction will set AH to 0FFh if the sign bit º (bit 7) of AL is set; if bit 7 of AL is not set, AH º will be set to 0. The instruction is useful for º generating a word from a byte prior to performing º byte division. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STC CMC STD CLD STI CLI Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºCLC Clear Carry Flag Flags: O D I T S Z A P C º 0 ºCLC º Logic: CF <- 0 º º CLC clears (sets to 0) the Carry Flag. No other flags are affected. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 2 - 1 CLC ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STD STC CLC CMC STI CLI Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºCLD Clear Direction Flag Flags: O D I T S Z A P C º º 0 º ºCLD º º Logic: DF <- 0 (Increment in string instructions) º º º º CLD zeros the Direction Flag. No other flags are affected. Clearing º º the direction flag causes string operations to increment SI and DI. º º º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 CLD º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: String instructions increment SI and DI when the º º direction flag is clear. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STI STC CLC CMC STD CLD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºCLI Clear Interrupt-Enable Flag Flags: O D I T S Z A P C º º 0 º ºCLI º º Logic: IF <- 0 º º º º CLI clears the Interrupt Enable Flag, suppressing processor º º recognition of maskable interrupts. No other flags are affected. (Non- º º maskable interrupts are recognized no matter what the state of the º º interrupt enable flag.) º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 CLI º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STC CLC STD CLD STI CLI Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºCMC Complement Carry Flag Flags: O D I T S Z A P C º º * º ºCMC º º Logic: CF <- -CF º º º º CMC reverses the current state of the Carry Flag. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 CMC º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CMPS SCAS EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºCMP Compare Flags: O D I T S Z A P C º º * * * * * * º ºCMP destination,source º º º º Logic: Flags set according to result of º º (destination - source) º º º º CMP compares two numbers by subtracting the source from the º º destination and updates the flags. CMP does not change the source or º º destination. The operands may be bytes or words. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º byte(word) º º register, register 3 - 2 CMP CX,BX º º register, immediate 4 - 3-4 CMP BL,02h º º accumulator, immediate 4 - 2-3 CMP AL,00010110b º º register, memory 9(13) + EA 1 2-4 CMP DH,ALPHA_BETA º º memory, register 9(13) + EA 1 2-4 CMP TOTAL,SI º º memory, immediate 10(14) + EA 1 3-6 CMP VALUES,3420h º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CMP CMPSB CMPSW SCAS REP CLD STD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºCMPS Compare String (Byte or Word) Flags: O D I T S Z A P C º * * * * * * ºCMPS destination-string,source-string º º Logic: CMP (DS:SI), (ES:DI) ; Sets flags only º if DF = 0 º SI <- SI + n ; n = 1 for byte, 2 for word º DI <- DI + n º else º SI <- SI - n º DI <- DI - n º º This instruction compares two values by subtracting the byte or word º pointed to by ES:DI, from the byte or word pointed to by DS:SI, and º sets the flags according to the results of the comparison. The º operands themselves are not altered. After the comparison, SI and DI º are incremented (if the direction flag is cleared) or decremented (if º the direction flag is set), in preparation for comparing the next º element of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º dest,source 22(30) 2 1 CMPS STR1,STR2 º (repeat) dest,source 9 + 22(30)/rep 2/rep 1 REPE CMPS STR1,STR2 º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: This instruction is always translated by the º assembler into either CMPSB, Compare String Byte, or º CMPSW, Compare String Word, depending upon whether º source refers to a string of bytes or words. In º either case, you must explicitly load the SI and DI º registers with the offset of the source and º destination strings. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Assuming the definition: º º buffer1 db 100 dup (?) º buffer2 db 100 dup (?) º the following example compares BUFFER1 against BUFFER2 for the first º mismatch. º º cld ;Scan in the forward direction º mov cx, 100 ;Scanning 100 bytes (CX is used by REPE) º lea si, buffer1 ;Starting address of first buffer º lea di, buffer2 ;Starting address of second buffer º repe cmps buffer1,buffer2 ;...and compare it. º jne mismatch ;The Zero Flag will be cleared if there º ;is a mismatch º match: . ;If we get here, buffers match º . º mismatch: º dec si ;If we get here, we found a mismatch. º dec di ;Back up SI and DI so they point to º . ;the first mismatch º . º Upon exit from the REPE CMPS loop, the Zero Flag will be cleared if a º mismatch was found, and set otherwise. If a mismatch was found, DI and º SI will be pointing one byte past the byte that didn't match; the DEC º DI and DEC SI backup these registers so they point to the mismatched º characters. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: CMP CMPS CMPSW SCAS REP CLD STD Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºCMPSB Compare String Byte Flags: O D I T S Z A P C º * * * * * * ºCMPSB º Logic: CMP (DS:SI), (ES:DI) ; Sets flags only º if DF = 0 º SI <- SI + 1 º DI <- DI + 1 º else º SI <- SI - 1 º DI <- DI - 1 º º This instruction compares two values by subtracting the byte pointed º to by ES:DI, from the byte pointed to by DS:SI, and sets the flags º according to the results of the comparison. The operands themselves º are not altered. After the comparison, SI and DI are incremented (if º the direction flag is cleared) or decremented (if the direction flag º is set), in preparation for comparing the next element of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 22 2 1 CMPSB º (repeat) 9 + 22/rep 2/rep 1 REPE CMPSB º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example compares BUFFER1 against BUFFER2 for the first º mismatch. º º cld ;Scan in the forward direction º mov cx, 100 ;Scanning 100 bytes (CX is used by REPE) º lea si, buffer1 ;Starting address of first buffer º lea di, buffer2 ;Starting address of second buffer º repe cmpsb ; ...and compare it. º jne mismatch ;The Zero Flag will be cleared if there º ; is a mismatch º match: . ;If we get here, buffers match º . º mismatch: º dec si ;If we get here, we found a mismatch. º dec di ;Back up SI and DI so they point to the º . ; first mismatch º Upon exit from the REPE CMPSB loop, the Zero Flag will be cleared if a º mismatch was found, and set otherwise. If a mismatch was found, DI and º SI will be pointing one byte past the byte that didn't match; the DEC º DI and DEC SI instructions backup these registers so they point to the º mismatched characters. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: CMP CMPS CMPSB SCAS REP CLD STD Flags ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºCMPSW Compare String Word Flags: O D I T S Z A P C º * * * * * * ºCMPSW º Logic: CMP (DS:SI), (ES:DI) ; Sets flags only º if DF = 0 º SI <- SI + 2 º DI <- DI + 2 º else º SI <- SI - 2 º DI <- DI - 2 º º This instruction compares two numbers by subtracting the word pointed º to by ES:DI, from the word pointed to by DS:SI, and sets the flags º according to the results of the comparison. The operands themselves º are not altered. After the comparison, SI and DI are incremented (if º the direction flag is cleared) or decremented (if the direction flag º is set), in preparation for comparing the next element of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 30 2 1 CMPSW º (repeat) 9 + 30/rep 2/rep 1 REPE CMPSW º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example compares BUFFER1 against BUFFER2 for the first º mismatch. º º cld ;Scan in the forward direction º mov cx, 50 ;Scanning 50 words (100 bytes) º lea si, buffer1 ;Starting address of first buffer º lea di, buffer2 ;Starting address of second buffer º repe cmpsw ; ...and compare it. º jne mismatch ;The Zero Flag will be cleared if there º ; is a mismatch º match: . ;If we get here, buffers match º . º mismatch: º dec si ;If we get here, we found a mismatch. º dec si ;Back up DI and SI so they point to the º dec di ; first mismatch º dec di º º Upon exit from the REPE CMPSW loop, the Zero Flag will be cleared if a º mismatch was found, and set otherwise. If a mismatch was found, DI and º SI will be pointing one word (two bytes) past the word that didn't º match; the DEC DI and DEC SI pairs backup these registers so they º point to the mismatched characters. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: CBW DIV IDIV ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ºCWD Convert Word to Doubleword Flags: not altered º ºCWD º Logic: if (AX < 8000h) then º DX <- 0 º else º DX <- FFFFh º º CWD extends the sign bit of the AX register into the DX register. This º instruction generates the double-word equivalent of the signed number º in the AX register. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 5 - 1 CWD º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: This instruction will set DX to 0FFFFh if the sign º bit (bit 15) of AX is set; if bit 15 of AX is not º set, DX will be set to 0. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: DAS AAA AAS AAM AAD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºDAA Decimal Adjust after Addition Flags: O D I T S Z A P C º ? * * * * * ºDAA º Logic: If (AL & 0Fh) > 9 or (AF = 1) then º AL <- AL + 6 º AF <- 1 º else AF <- 0 º If (AL > 9Fh) or (CF = 1) then º AL <- AL + 60h º CF <- 1 º else CF <- 0 º º DAA corrects the result of a previous addition of two valid packed º decimal operands (note that this result must be in AL). This º instruction changes the content of AL so that it will contain a pair º of valid packed decimal digits. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 4 - 1 DAA º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: Packed BCD stores one digit per nibble (4 bits); the º least significant digit is in the lower nibble. º º It is not possible to apply an adjustment after º division or multiplication of packed BCD numbers. º If you need to use multiplication or division, it is º better to use unpacked BCD numbers. See, for º example, the description of AAM (ASCII Adjust after º Multiply). ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: AAS DAA SUB SBB DEC NEG Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºDAS Decimal Adjust after Subtraction Flags: O D I T S Z A P C º ? * * * * * ºDAS º Logic: If (AL & 0Fh) > 9 or (AF = 1) then º AL <- AL - 6 º AF <- 1 º else AF <- 0 º If (AL > 9Fh) or (CF = 1) then º AL <- AL - 60h º CF <- 1 º else CF <- 0 º º DAS corrects the result of a previous subtraction of two valid packed º decimal operands (note that this result must be in AL). This º instruction changes the content of AL so that it will contain a pair º of valid packed decimal digits. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 4 - 1 DAS º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: Packed BCD stores one digit per nibble (4 bits); the º least significant digit is in the lower nibble. º º It is not possible to apply an adjustment after º division or multiplication of packed BCD numbers. º If you need to use multiplication or division, it is º better to use unpacked BCD numbers. See, for º example, the description of AAM (ASCII Adjust after º Multiply). ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SUB SBB AAS DAS EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºDEC Decrement Flags: O D I T S Z A P C º º * * * * * º ºDEC destination º º º º Logic: destination <- destination - 1 º º º º This instruction decrements the destination by one. The destination º º operand, which may be either a word or a byte, is treated as an º º unsigned binary number. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º reg16 2 - 1 DEC BX º º reg8 3 - 2 DEC BL º º memory 15(23) + EA 2 2-4 DEC MATRIX[SI] º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: This instruction does not set the carry, so if you º º need to decrement a multi-word number, it is better º º to use the SUB and SBB instructions. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: IDIV SHR AAD CBW CWD INT 00h EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºDIV Divide, Unsigned Flags: O D I T S Z A P C º ? ? ? ? ? ? ºDIV source º Logic: AL <- AX / source ; Source is byte º AH <- remainder º or º AX <- DX:AX / source ; Source is word º DX <- remainder º º This instruction performs unsigned division. If the source is a byte, º DIV divides the word value in AX by source, returning the quotient in º AL and the remainder in AH. If the source is a word, DIV divides the º double-word value in DX:AX by the source, returning the quotient in AX º and the remainder in DX. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg8 0-90 - 2 DIV BL º reg16 4-162 - 2 DIV BX º mem8 (86-96) + EA 1 2-4 DIV VYUP º mem16 (154-172) + EA 1 2-4 DIV NCONQUER[SI] º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: If the result is too large to fit in the destination º (AL or AX), an INT 0 (Divide by Zero) is generated, º and the quotient and remainder are undefined. º º When an Interrupt 0 (Divide by Zero) is generated, º the saved CS:IP value on the 80286 and 80386 points º to the instruction that failed (the DIV º instruction). On the 8088/8086, however, CS:IP º points to the instruction following the failed DIV º instruction. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: HLT WAIT LOCK EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºESC Escape Flags: not altered º ºESC coprocessor's-opcode,source º º ESC is used to pass control from the microprocessor to a coprocessor, º such as an 8087 or 80287. In response to ESC, the microprocessor º accesses a memory operandÄÄthe instruction for the coprocessorÄÄand º places it on the bus. The coprocessor watches for ESC commands and º executes the instruction placed on the bus, using the effective º address of source. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º immediate, memory 8(12) + EA 1 2-4 ESC 6,ADR[SI] º immediate, register 2 - 2 ESC COPROC-CODE,AH º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: In order to synchronize with the math coprocessor, º the programmer must explicitly code the WAIT º instruction preceding all ESC instructions. The º 80286 and 80386 have automatic instruction º synchronization, hence WAITs are not needed. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: WAIT ESC LOCK º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºHLT Halt the Processor Flags: not altered º º º ºHLT º º º º This instruction halts the CPU. The processor leaves the halted state º º in response to a non-maskable interrupt; a maskable interrupt with º º interrupts enabled; or activation of the reset line. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 HLT º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: DIV SAR AAD CBW CWD INT 00h EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºIDIV Integer Divide, Signed Flags: O D I T S Z A P C º ? ? ? ? ? ? ºIDIV source º º Logic: AL <- AX / source ; Byte source º AH <- remainder º or º AX <- DX:AX / source ; Word source º DX <- remainder º º IDIV performs signed division. If source is a byte, IDIV divides the º word value in AX by source, returning the quotient in AL and the º remainder in AH. If source is a word, IDIV divides the double-word º value in DX:AX by source, returning the quotient in AX and the º remainder in DX. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg8 101-112 - 2 IDIV CL º reg16 165-184 - 2 IDIV DX º mem8 (107-118) + EA 1 2-4 IDIV BYTE[SI] º mem16 (175-194) + EA 1 2-4 IDIV [BX].WORD_ARRAY º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: If the result is too large to fit in the destination º (AL or AX), an INT 0 (Divide by Zero) is generated, º and the quotient and remainder are undefined. º The 80286 and 80386 microprocessors are able to º generate the largest negative number (80h or 8000h) º as a quotient for this instruction, but the º 8088/8086 will generate an Interrupt 0 (Divide by º Zero) if this situation occurs. º When an Interrupt 0 (Divide by Zero) is generated, º the saved CS:IP value on the 80286 and 80386 points º to the instruction that failed (the IDIV º instruction). On the 8088/8086, however, CS:IP º points to the instruction following the failed IDIV º instruction. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: MUL AAM EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºIMUL Integer Multiply, Signed Flags: O D I T S Z A P C º * ? ? ? ? * ºIMUL source º º Logic: AX <- AL * source ; if source is a byte º or º DX:AX <- AX * source ; if source is a word º º IMUL performs signed multiplication. If source is a byte, IMUL º multiplies source by AL, returning the product in AX. If source is a º word, IMUL multiplies source by AX, returning the product in DX:AX. º The Carry Flag and Overflow Flag are set if the upper half of the º result (AH for a byte source, DX for a word source) contains any º significant digits of the product, otherwise they are cleared. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg8 80-98 - 2 IMUL CL º reg16 128-154 - 2 IMUL BX º mem8 (86-104) + EA 1 2-4 IMUL BITE º mem16 (138-164) + EA 1 2-4 IMUL WORD[BP][DI] ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: OUT º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºIN Input Byte or Word Flags: not altered º º º ºIN accumulator,port º º º º Logic: accumulator <- (port) º º º º IN transfers a byte or a word from a port to AL or AX. The port may be º º specified by an immediate byte value (for ports 0 through 255) or by º º the DX register (allowing access to all ports). º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º byte(word) º º accumulator, immed8 10(14) 1 2 IN AL,45h º º accumulator, DX 8(12) 1 1 IN AX,DX º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: It is advised that hardware not use I/O ports F8h º º through FFh, since these are reserved for º º controlling the math coprocessor and future º º processor extensions. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: ADD ADC AAA DAA DEC EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºINC Increment Flags: O D I T S Z A P C º º * * * * * º ºINC destination º º º º Logic: destination <- destination + 1 º º º º INC adds 1 to the destination. The destination, which may be either a º º byte or a word, is considered an unsigned binary number. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º byte(word) º º reg16 2 - 1 INC BX º º reg8 3 - 2 INC BL º º memory 15(23) + EA 2 2-4 INC THETA[BX] º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: This instruction does not set the carry flag. If º º you need to add 1 to a multi-word number, it is º º better to use the ADD and ADC instructions instead. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: IRET INTO PUSHF CALL PUSHF INT 03h Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºINT Interrupt Flags: O D I T S Z A P C º 0 0 ºINT interrupt-num º º Logic: PUSHF ; Push flags onto stack º TF <- 0 ; Clear Trap Flag º IF <- 0 ; Disable Interrupts º CALL FAR (INT*4) ; Call the interrupt handler º º INT pushes the flags register, clears the Trap and Interrupt-enable º Flags, pushes CS and IP, then transfers control to the interrupt º handler specified by the interrupt-num. If the interrupt handler º returns using an IRET instruction, the original flags are restored. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º immed8 (type = 3) 52 5 1 INT 3 º immed8 (type <> 3) 51 5 2 INT 21 º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: The flags are stored in the same format as that used º by the PUSHF instruction. º The address of the interrupt vector is determined by º multiplying the interrupt-num by 4. The first word º at the resulting address is loaded into IP, and the º second word into CS. º All interrupt-nums except type 3 generate a two-byte º opcode; type 3 generates a one-byte instruction º called the Breakpoint interrupt. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: INT IRET JNO JO PUSHF CALL INT 04h Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºINTO Interrupt on Overflow Flags: O D I T S Z A P C º 0 0 ºINTO º Logic: if (OF = 1) º PUSHF ; Push flags onto stack º TF <- 0 ; Clear Trap Flag º IF <- 0 ; Disable Interrupts º CALL FAR (10h) ; The INTO vector is at 0000:0010h º º INTO activates interrupt type 4 if the Overflow Flag is set; otherwise º it does nothing. This interrupt operates identically to an "INT 4" if º the overflow flag is set, in which case INTO pushes the flags º register, clears the Trap and Interrupt-enable Flags, pushes CS and º IP, then transfers control to the interrupt-num 4 handler, which is º pointed to by the vector at location 10h. If the interrupt handler º returns using an IRET instruction, the original flags are restored. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º no operands 53 or 4 5 1 INTO º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: The flags are stored in the same format as that used º by the PUSHF instruction. º INTO can be used after an operation that may cause º overflow, to call a recovery procedure. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: INT INTO POP POPF º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºIRET Interrupt Return Flags: O D I T S Z A P C º º r r r r r r r r r º ºIRET º º Logic: POP IP º º POP CS º º POPF ; Pop flags from stack º º º º IRET returns control from an interrupt routine to the point where the º º interrupt occurred, by popping IP, CS, and the Flag registers. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 32 3 1 IRET º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNBE JAE JG JBE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJA Jump If Above Flags: not altered º ºJA short-label º º Jump Condition: Jump if CF = 0 and ZF = 0 º º Used after a CMP or SUB instruction, JA transfers control to short- º label if the first operand (which should be unsigned) was greater than º the second operand (also unsigned). The target of the jump must be º within -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JA ABOVE º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNBE, Jump Not Below or Equal, is the same º instruction as JA. º JA, Jump on Above, should be used when comparing º unsigned numbers. º JG, Jump on Greater, should be used when comparing º signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNB JA JGE JB º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJAE Jump If Above or Equal Flags: not altered º ºJAE short-label º º Jump Condition: Jump if CF = 0 º º Used after a CMP or SUB instruction, JAE transfers control to short- º label if the first operand (which should be unsigned) was greater than º or equal to the second operand (also unsigned). The target of the jump º must be within -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JAE ABOVE_EQUAL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNB (Jump Not Below) is the same instruction as JAE. º JAE, Jump on Above or Equal, should be used when º comparing unsigned numbers. º JGE, Jump on Greater or Equal, should be used when º comparing signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNAE JC JL JAE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJB Jump If Below Flags: not altered º ºJB short-label º º Jump Condition: Jump if CF = 1 º º Used after a CMP or SUB instruction, JB transfers control to short- º label if the first operand was less than the second. (Both operands º are treated as unsigned numbers.) The target of the jump must be º within -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JB BELOW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JC (Jump if Carry), JB, and JNAE (Jump if Not Above º or Equal), are all synonyms for the same º instruction. º JB, Jump if Below, should be used when comparing º unsigned numbers. º JL, Jump if Less Than, should be used when comparing º signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNA JLE JA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJBE Jump If Below or Equal Flags: not altered º ºJBE short-label º º Jump Condition: Jump if CF = 1 or ZF = 1 º º Used after a CMP or SUB instruction, JBE transfers control to short- º label if the first operand was less than or equal to the second. (Both º operands are treated as unsigned numbers.) The target of the jump º must be within -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JBE NOT_ABOVE º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNA, Jump if Not Above, is the same instruction as º JBE. º JBE, Jump if Below or Equal, should be used when º comparing unsigned numbers. º JLE, Jump if Less Than or Equal, should be used when º comparing signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JB JNAE JNC º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJC Jump If Carry Flags: not altered º º º ºJC short-label º º º º Jump Condition: Jump if CF = 1 º º º º JC transfers control to short-label if the Carry Flag is set. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JC CARRY_SET º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: JB (Jump if Below), JC, and JNAE (Jump if Not Above º º or Equal) are all synonyms for the same instruction. º º Use JNC, Jump if No Carry, to jump if the carry flag º º is clear. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LOOP LOOPE LOOPZ LOOPNZ LOOPNE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJCXZ Jump If CX Register Zero Flags: not altered º º º ºJCXZ short-label º º º º Jump Condition: Jump if CX = 0 º º º º JCXZ transfers control to short-label if the CX register is 0. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 18 or 6 - 2 JCXZ COUNT_DONE º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: This instruction is commonly used at the beginning º º of a loop to bypass the loop if the counter variable º º (CX) is at 0. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JZ JNE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJE Jump If Equal Flags: not altered º º º ºJE short-label º º º º Jump Condition: Jump if ZF = 1 º º º º Used after a CMP or SUB instruction, JE transfers control to short- º º label if the first operand is equal to the second operand. The target º º of the jump must be within -128 to +127 bytes of the next instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JE ZERO º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: JZ, Jump if Zero, is the same instruction as JE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNLE JA JLE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJG Jump If Greater Flags: not altered º ºJG short-label º º Jump Condition: Jump if ZF = 0 and SF = OF º º Used after a CMP or SUB instruction, JG transfers control to short- º label if the first operand is greater than the second. (Both operands º are treated as signed numbers.) The target of the jump must be within º -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JG GREATER º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNLE, Jump if Not Less or Equal, is the same º instruction as JG. º JA, Jump if Above, should be used when comparing º unsigned numbers. º JG, Jump if Greater, should be used when comparing º signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNL JAE JL º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJGE Jump If Greater or EQual Flags: not altered º ºJGE short-label º º Jump Condition: Jump if SF = OF º º Used after a CMP or SUB instruction, JGE transfers control to short- º label if the first operand is greater than or equal to the second. º (Both operands are treated as signed numbers.) The target of the jump º must be within -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JGE GREATER_EQUAL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNL, Jump if Not Less, is the same instruction as º JGE. º JAE, Jump if Above or Equal, should be used when º comparing unsigned numbers. º JGE, Jump if Greater or Equal, should be used when º comparing signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNGE JB JGE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJL Jump If Less Flags: not altered º ºJL short-label º Jump Condition: Jump if SF <> OF º º Used after a CMP or SUB instruction, JL transfers control to short- º label if the first operand is less than the second. (Both operands are º treated as signed numbers.) The target of the jump must be within - º 128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JL LESS º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNGE, Jump if Not Greater or Equal, is the same º instruction as JL. º JB, Jump if Below, should be used when comparing º unsigned numbers. º JL, Jump if Less, should be used when comparing º signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNG JBE JNA JG º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJLE Jump If Less or Equal Flags: not altered º ºJLE short-label º º Jump Condition: Jump if SF <> OF or ZF = 1 º º Used after a CMP or SUB instruction, JLE transfers control to short- º label if the first operand is less than or equal to the second . (Both º operands are treated as signed numbers.) The target of the jump must º be within -128 to +127 bytes of the next instruction. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 16 or 4 - 2 JLE NOT_GREATER º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: JNG, Jump if Not Greater, is the same instruction as º JLE. º JBE, Jump if Below or Equal, should be used when º comparing unsigned numbers. º JLE, Jump if Less or Equal, should be used when º comparing signed numbers. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CALL RET SHORT NEAR FAR PROC EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJMP Jump Unconditionally Flags: not altered º ºJMP target º º Jump Condition: Jump always º º JMP always transfer control to the target location. Unlike CALL, JMP º does not save IP, because no RETurn is expected. An intrasegment JMP º may be made either through memory or through a 16-bit register; an º intersegment JMP can be made only through memory. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º short-label 15 - 2 JMP ROPE_NEAR º near-label 15 - 3 JMP SAME_SEGMENT º far-label 15 - 5 JMP FAR_LABEL º memptr16 18 + EA - 2-4 JMP SAME_SEG º regptr16 11 - 2 JMP BX º memptr32 24 + EA - 2-4 JMP NEXT_SEG º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: If the assembler can determine that the target of an º intrasegment jump is within 127 bytes of the current º location, the assembler will automatically generate º a short-jump (two-byte) instruction; otherwise, a 3- º byte NEAR JMP is generated. º You can force the generation of a short jump by º explicit use of the operator "short," as in: º º JMP short near_by ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JBE JLE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNA Jump If Not Above Flags: not altered º º º ºJNA short-label º º º º JNA is a synonym for JBE. See the description for JBE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JB JL º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNAE Jump If Not Above or Equal Flags: not altered º º º ºJNAE short-label º º º º JNAE is a synonym for JB. See the description for JB. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JAE JGE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNB Jump If Not Below Flags: not altered º º º ºJNB short-label º º º º JNB is a synonym for JAE. See the description for JAE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JA JG º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNBE Jump If Not Below or Equal Flags: not altered º º º ºJNBE short-label º º º º JNBE is a synonym for JA. See the description for JA. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JC º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNC Jump If No Carry Flags: not altered º º º ºJNC short-label º º º º Jump Condition: Jump if CF = 0 º º º º JNC transfers control to short-label if the Carry Flag is clear. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JNC CARRY_CLEAR º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: Use JC, Jump if Carry, to jump if the carry flag is º º set. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNZ JE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNE Jump If Not Equal Flags: not altered º º º ºJNE short-label º º º º Jump Condition: Jump if ZF = 0 º º º º Used after a CMP or SUB instruction, JNE transfers control to short- º º label if the first operand is not equal to the second. The target of º º the jump must be within -128 to +127 bytes of the next instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JNE NOT_EQUAL º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: JNZ, Jump if Not Zero, is the same instruction as º º JNE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JLE JBE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNG Jump If Not Greater Flags: not altered º º º ºJNG short-label º º º º JNG is a synonym for JLE. See the description for JLE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JL JB º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNGE Jump If Not Greater or Equal Flags: not altered º º º ºJNGE short-label º º º º JNGE is a synonym for JL. See the description for JL. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JGE JAE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNL Jump If Not Less Flags: not altered º º º ºJNL short-label º º º º JNL is a synonym for JGE. See the description for JGE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JG JA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNLE Jump If Not Less or Equal Flags: not altered º º º ºJNLE short-label º º º º JNLE is a synonym for JG. See the description for JG. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JO INTO º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNO Jump If No Overflow Flags: not altered º º º ºJNO short-label º º º º Jump Condition: Jump if OF = 0 º º º º JNO transfers control to short-label if the Overflow Flag is clear. º º The target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JNO NO_OVERFLOW º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: Use JO, Jump if Overflow, to jump if the overflow º º flag is set. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JPO JP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNP Jump If No Parity Flags: not altered º º º ºJNP short-label º º º º Jump Condition: Jump if PF = 0 º º º º JNP transfers control to short-label if the Parity Flag is clear. The º º target of the jump must be within -128 or +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JNP ODD_PARITY º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: JPO, Jump if Parity Odd, is the same instruction a º º JNP. º º Use JP, Jump on Parity, to jump if the parity flag º º is set. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JS º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNS Jump If No Sign Flags: not altered º º º ºJNS short-label º º º º Jump Condition: Jump if SF = 0 º º º º JNS transfers control to short-label if the Sign Flag is clear. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JNS AQUARIUS º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: Use JS, Jump if Sign, to jump if the sign flag is º º set. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNE JE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJNZ Jump If Not Zero Flags: not altered º º º ºJNZ short-label º º º º JNZ is a synonym for JNE. See the description for JNE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNO INTO º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJO Jump If Overflow Flags: not altered º º º ºJO short-label º º º º Jump Condition: Jump if OF = 1 º º º º JO transfers control to short-label if the Overflow Flag is set. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JO SIGNED_OVERFLOW º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: Use JNO, Jump if No Overflow, to jump if the º º overflow flag is clear. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JPE JNP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJP Jump If Parity Flags: not altered º º º ºJP short-label º º º º Jump Condition: Jump if PF = 1 º º º º JP transfers control to short-label if the Parity Flag is set. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JP EVEN_PARITY º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: JPE, Jump if Parity Even, is the same instruction as º º JP. º º Use JNP, Jump if No Parity, to jump if the Parity º º Flag is clear. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JP JNP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJPE Jump If Parity Even Flags: not altered º º º ºJPE short-label º º º º JPE is a synonym for JP. See the description for JP. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNP JP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJPO Jump If Parity Odd Flags: not altered º º º ºJPO short-label º º º º JPO is a synonym for JNP. See the description for JNP. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JNS º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJS Jump If Sign Flags: not altered º º º ºJS short-label º º º º Jump Condition: Jump if SF = 1 º º º º JS transfers control to short-label if the Sign Flag is set. The º º target of the jump must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 16 or 4 - 2 JS NEGATIVE º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: Use JNS, Jump if No Sign, to jump if the sign flag º º is clear. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: JE JNE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºJZ Jump If Zero Flags: not altered º º º ºJZ short-label º º º º JZ is a synonym for JE. See the description for JE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SAHF PUSHF POPF º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLAHF Load Register AH from Flags Flags: not altered º º º º Logic: AH bits <- Flag-reg bits º º 7 6 4 2 0 <- S Z A P C º º º º LAHF copies the five 8080/8085 flags (Sign, Zero, Auxiliary Carry, º º Parity, and Carry) into bits 7, 6, 4, 2, and 0, respectively, of the º º AH register. The flags themselves are unchanged by this instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 4 - 1 LAHF º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: This instruction is primarily used to provide upward º º compatibility between the 8080/8085 family and the º º 8086 family. º º After this instruction is executed, bits 1, 3 and 5 º º of AH are undefined. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LEA LES OFFSET EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLDS Load Pointer using DS Flags: not altered º ºLDS destination,source º º Logic: DS <- (source + 2) º destination <- (source) º º LDS loads into two registers the 32-bit pointer variable found in º memory at source. LDS stores the segment value (the higher order word º of source) in DS and the offset value (the lower order word of source) º in the destination register. The destination register may be any any º 16-bit general register (that is, all registers except segment º registers). º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg16, mem32 24 + EA 2 2-4 LDS DI,32_POINTER º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: LES, Load Pointer Using ES, is a comparable º instruction that loads the ES register rather than º the DS register. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LDS LES OFFSET EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLEA Load Effective Address Flags: not altered º ºLEA destination,source º º Logic: destination <- Addr(source) º º LEA transfers the offset of the source operand (rather than its value) º to the destination operand. The source must be a memory reference, and º the destination must be a 16-bit general register. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg16, mem16 2 + EA - 2-4 LEA BX,MEM_ADDR º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: This instruction has an advantage over using the º OFFSET operator with the MOV instruction, in that º the source operand can be subscripted. For example, º this is legal: º LEA BX, TABLE[SI] ;Legal º whereas º MOV BX, OFFSET TABLE[SI] ;Not legal º is illegal, since the OFFSET operator performs its º calculation at assembly time and this address is not º known until run time. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The DOS print string routine, Function 09h, requires a pointer to the º string to be printed in DS:DX. If the string you wished to print was º at address "PRINT-ME" in the same data segment, you could load DS:DX º with the required pointer using this instruction: º º LEA DX, PRINT-ME ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LEA LDS OFFSET EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLES Load Pointer using ES Flags: not altered º ºLES dest-reg,source º º Logic: ES <- (source) º dest-reg <- (source + 2) º º LES loads into two registers the 32-bit pointer variable found in º memory at source. LES stores the segment value (the higher order word º of source) in ES and the offset value (the lower order word of source) º in the destination register. The destination register may be any any º 16-bit general register (that is, all registers except segment º registers). º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg16, mem32 24 + EA 2 2-4 LES DI, STR_ADDR º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: LDS, Load Pointer Using DS, is a comparable º instruction that loads the DS register rather than º the ES register. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: HLT WAIT ESC º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLOCK Lock the Bus Flags: not altered º ºLOCK º LOCK is a one-byte prefix that can precede any instruction. LOCK º causes the processor to assert its bus lock signal while the º instruction that follows is executed. If the system is configured such º that the LOCK signal is used, it prevents any external device or event º from accessing the bus, including interrupts and DMA transfers. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º no operands 2 - 1 LOCK XCHG FLAG,AL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: This instruction was provided to support multiple º processor systems with shared resources. In such a º system, access to those resources is generally º controlled via a software-hardware combination using º semaphores. º This instruction should only be used to prevent º other bus masters from interrupting a data movement º operation. This prefix should only be used with º XCHG, MOV, and MOVS. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LODSB LODSW CMPS MOVS SCAS STOS REP CLD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLODS Load String (Byte or Word) Flags: not altered º ºLODS source-str º º Logic: Accumulator <- (DS:SI) º if DF = 0 º SI <- SI + n ; n = 1 for byte, 2 for word scan º else º SI <- SI - n º º LODS transfers the value (word or byte) pointed to by DS:SI into AX or º AL. It also increments or decrements SI (depending on the state of º the Direction Flag) to point to the next element. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º source-str 12(16) - 1 LODS LIST º (repeat) source-str 9+13(17)/rep 1/rep 1 REP LODS LIST ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ º Notes: This instruction is always translated by the º assembler into either LODSB, Load String Byte, or º LODSW, Load String Word, depending upon whether º source-str refers to a string of bytes or words. In º either case, however, you must explicitly load the º SI register with the offset of the string. º º Although it is legal to repeat this instruction, it º is almost never done since doing so would º continually overwrite the value in AL. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example sends the eight bytes at INIT_PORT to port 250. º (Don't try this on your machine, unless you know what's hanging off º port 250.) º º INIT_PORT: º DB '$CMD0000' ;The string we want to send º . º . º CLD ;Move forward through string at INIT_PORT º LEA SI,INIT_PORT ;SI gets starting address of string º MOV CX,8 ;CX is counter for LOOP instruction º AGAIN: LODS INIT_PORT ;"INIT_PORT" is needed only by the º OUT 250,AL ; assembler, for determining word or byte º LOOP AGAIN ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LODS LODSW CMPS MOVS SCAS STOS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLODSB Load String Byte Flags: not altered º ºLODSB º Logic: AL <- (DS:SI) º if DF = 0 º SI <- SI + 1 º else º SI <- SI - 1 º º LODSB transfers the byte pointed to by DS:SI into AL and increments or º decrements SI (depending on the state of the Direction Flag) to point º to the next byte of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 12 - 1 LODSB º (repeat) 9+13/rep 1/rep 1 REP LODSB º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: Although it is legal to repeat this instruction, it º is almost never done since doing so would º continually overwrite the value in AL. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example sends the eight bytes at INIT_PORT to port 250. º (Don't try this on your machine, unless you know what's hanging off º port 250.) º º INIT_PORT: º DB '$CMD0000' ;The string we want to send º . º . º CLD ;Move forward through string at INIT_PORT º LEA SI, INIT_PORT ;SI gets starting address of string º MOV CX, 8 ;CX is counter for LOOP instruction º AGAIN: LODSB ;Load a byte into AL... º OUT 250,AL ; ...and output it to the port. º LOOP AGAIN ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LODS LODSB CMPS MOVS SCAS STOS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLODSW Load String Word Flags: not altered º ºLODSW º Logic: AX <- (DS:SI) º if DF = 0 º SI <- SI + 2 º else º SI <- SI - 2 º º LODSW transfers the word pointed to by DS:SI into AX and increments or º decrements SI (depending on the state of the Direction Flag) to point º to the next word of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 16 - 1 LODSW º (repeat) 9+17/rep 1/rep 1 REP LODSW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: Although it is legal to repeat this instruction, it º is almost never done since doing so would º continually overwrite the value in AL. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example sends the eight bytes at INIT_PORT to port 250. º (Don't try this on your machine, unless you know what's hanging off º port 250.) º º INIT_PORT: º DB '$CMD0000' ;The string we want to send º . º . º CLD ;Move forward through string at INIT_PORT º LEA SI, INIT_PORT ;SI gets starting address of string º MOV CX, 4 ;Moving 4 words (8 bytes) º AGAIN: LODSW ;Load a word into AX... º OUT 250,AX ; ...and output it to the port. º LOOP AGAIN ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LOOPE LOOPNE LOOPNZ LOOPZ JCXZ º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLOOP Loop on Count Flags: not altered º º º ºLOOP short-label º º º º Logic: CX <- CX - 1 º º If (CX <> 0) º º JMP short-label º º º º LOOP decrements CX by 1, then transfers control to short-label if CX º º is not 0. Short-label must be within -128 to +127 bytes of the next º º instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 17/5 - 2 LOOP AGAIN º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LOOP LOOPNE LOOPNZ LOOPZ JCXZ º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLOOPE Loop While Equal Flags: not altered º º º ºLOOPE short-label º º º º Logic: CX <- CX - 1 º º If CX <> 0 and ZF = 1 º º JMP short-label º º º º Used after a CMP or SUB, LOOPE decrements CX by 1, then transfers º º control to short-label if the first operand of the CMP or SUB is equal º º to the second operand. Short-label must be within -128 to +127 bytes º º of the next instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 18 or 6 - 2 LOOPE AGAIN º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: LOOPZ, Loop if Zero, is the same instruction. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LOOPZ LOOP LOOPE LOOPNZ JCXZ º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLOOPNE Loop While not Equal Flags: not altered º º º ºLOOPNE short-label º º º º Logic: CX <- CX - 1 º º If CX <> 0 and ZF = 0 º º JMP short-label º º º º Used after a CMP or SUB, LOOPNE decrements CX by 1, then transfers º º control to short-label if the first operand of the CMP or SUB is not º º equal to the second operand. Short-label must be within -128 to +127 º º bytes of the next instruction. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º short-label 19 or 5 - 2 LOOPNE AGAIN º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: LOOPNZ, Loop While Not Zero, is the same º º instruction. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LOOPNE LOOP LOOPE JCXZ º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLOOPNZ Loop While not Zero Flags: not altered º º º ºLOOPNZ short-label º º º º LOOPNZ is a synonym for LOOPNE. See the description for LOOPNE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LOOPE LOOP LOOPNE JCXZ º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºLOOPZ Loop While Zero Flags: not altered º º º ºLOOPZ short-label º º º º LOOPZ is a synonym for LOOPE. See the description for LOOPE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: MOVS PUSH POP XCHG XLAT EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºMOV Move (Byte or Word) Flags: not altered º ºMOV destination,source º º Logic: destination <- source º º MOV copies a byte or word from the source into the destination. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 2 - 2 MOV BX,CX º memory, accumulator 10(14) 1 3 MOV MEM_DEST,AL º accumulator, memory 10(14) 1 3 MOV AX,MEM_SOURCE º memory, register 9(13) + EA 1 2-4 MOV MEM_DEST,BX º register, memory 8(12) + EA 1 2-4 MOV BX,MEM_SOURCE º register, immediate 4 - 2-3 MOV BX,0F6CDh º memory, immediate 10(14) + EA 1 3-6 MOV MASK,0F6CDh º seg-reg, reg16 2 - 2 MOV DS,BX º seg-reg, mem16 8(12) + EA 1 2-4 MOV DS,SEGMENT_VAL º reg16, seg-reg 2 - 2 MOV BP,SS º memory, seg-reg 9(13) + EA 1 2-4 MOV CODE_VAR,CS ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: MOV MOVSB MOVSW CMPS LODS SCAS STOS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºMOVS Move String (Byte or Word) Flags: not altered º ºMOVS destination-string,source-string º º Logic: (ES:DI) <- (DS:SI) º if DF = 0 º SI <- SI + n ; n = 1 for byte, 2 for word scan º DI <- DI + n º else º SI <- SI - n º DI <- DI - n º º This instruction copies the byte or word pointed to by DS:SI, into the º location pointed to by ES:DI. After the move, SI and DI are º incremented (if the direction flag is cleared) or decremented (if the º direction flag is set), to point to the next element of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º dest,source 18(26) 2 1 MOVS WORD_BUFF,INPUT º (repeat) dest,source 9+17(25)/rep 2/rep 1 REP MOVSW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: This instruction is always translated by the º assembler into either MOVSB, Move String Byte; or º MOVSW, Move String Word, depending upon whether º source-string refers to a string of bytes or words. º In either case, you must explicitly load the SI and º DI registers with the offset of the source and º destination strings. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Assuming BUFFER1 as been defined somewhere as: º º BUFFFER1 DB 100 DUP (?) º º the following example moves 100 bytes from BUFFER1 to BUFFER2: º º CLD ;Move in the forward direction º LEA SI, BUFFER1 ;Source address to SI º LEA DI, BUFFER2 ;Destination address to DI º MOV CX,100 ;CX is used by the REP prefix º REP MOVS BUFFER2, BUFFER1 ; ...and MOVS it. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: MOV MOVS MOVSW CMPS LODS SCAS STOS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºMOVSB Move String Byte Flags: not altered º ºMOVSB º º Logic: (ES:DI) <- (DS:SI) º if DF = 0 º SI <- SI + 1 º DI <- DI + 1 º else º SI <- SI - 1 º DI <- DI - 1 º º This instruction copies the byte pointed to by DS:SI into the location º pointed to by ES:DI. After the move, SI and DI are incremented (if the º direction flag is cleared) or decremented (if the direction flag is º set), to point to the next byte. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 18 2 1 MOVSB º (repeat) 9+17/rep 2/rep 1 REP MOVSB º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Assuming BUFFER1 as been defined somewhere as: º º BUFFFER1 DB 100 DUP (?) º º the following example moves 100 bytes from BUFFER1 to BUFFER2: º º CLD ;Move in the forward direction º LEA SI, BUFFER1 ;Source address to SI º LEA DI, BUFFER2 ;Destination address to DI º MOV CX,100 ;CX is used by the REP prefix º REP MOVSB ; ...and move it. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: MOV MOVS MOVSB CMPS LODS SCAS STOS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºMOVSW Move String Word Flags: not altered º ºMOVSW º Logic: (ES:DI) <- (DS:SI) º if DF = 0 º SI <- SI + 2 º DI <- DI + 2 º else º SI <- SI - 2 º DI <- DI - 2 º º This instruction copies the word pointed to by DS:SI to the location º pointed to by ES:DI. After the move, SI and DI are incremented (if the º direction flag is cleared) or decremented (if the direction flag is º set), to point to the next word. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 26 2 1 MOVSW º (repeat) 9+25/rep 2/rep 1 REP MOVSW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Assuming BUFFER1 as been defined somewhere as: º º BUFFFER1 DB 100 DUP (?) º º the following example moves 50 words (100 bytes) from BUFFER1 to º BUFFER2: º º CLD ;Move in the forward direction º LEA SI, BUFFER1 ;Source address to SI º LEA DI, BUFFER2 ;Destination address to DI º MOV CX,50 ;Used by REP; moving 50 words º REP MOVSW ; ...and move it. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: IMUL AAM EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºMUL Multiply, Unsigned Flags: O D I T S Z A P C º * ? ? ? ? * ºMUL source º º Logic: AX <- source * AL ; if source is a byte º or º DX:AX = source * AX ; if source is a word º º MUL performs unsigned multiplication. If source is a byte, MUL º multiplies source by AL, returning the product in AX. If source is a º word, MUL multiplies source by AX, returning the product in DX:AX. The º Carry and Overflow flags are set if the upper half of the result (AH º for a byte source, DX for a word source) contains any significant º digits of the product, otherwise they are cleared. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º reg8 70-77 - 2 MUL CH º reg16 118-133 - 2 MUL BX º mem8 (76-83) + EA 1 2-4 MUL A_BYTE º mem16 (128-143) + EA 1 2-4 MUL A_WORD ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: NOT SUB SBB AAS DAS EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºNEG Negate Flags: O D I T S Z A P C º * * * * * * ºNEG destination º º Logic: destination <- -destination ; two's complement º º NEG subtracts the destination operand from 0 and returns the result in º the destination. This effectively produces the two's complement of the º operand. The operand may be a byte or a word. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register 3 - 2 NEG DL º memory 16(24) + EA 2 2-4 NEG COEFFICIENT º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: If the operand is zero, the carry flag is cleared; º in all other cases, the carry flag is set. º º Attempting to negate a byte containing -128 or a º word containing -32,768 causes no change to the º operand and sets the Overflow Flag. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ºNOP No Operation Flags: not altered º º º º Logic: None º º º º NOP causes the processor to do nothing. This instruction is frequently º º used for timing purposes, to force memory alignment, and as a "place- º º holder." º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 3 - 1 NOP º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: NEG AND OR XOR EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºNOT Logical NOT Flags: not altered º º º ºNOT destination º º º º Logic: destination <- NOT(destination) ; one's complement º º º º NOT inverts each bit of its operand (that is, forms the one's º º complement). The operand can be a word or byte. º º º º NOT Instruction Logic º º º º Destination Result º º 0 1 º º 1 0 º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º byte(word) º º register 3 - 2 NOT DX º º memory 16(24) + EA 2 2-4 NOT MASK º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: AND NOT XOR EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºOR Logical OR Flags: O D I T S Z A P C º 0 * * ? * 0 ºOR destination,source º º Logic: destination <- destination OR source º º OR performs a bit-by-bit logical inclusive OR operation on its º operands and returns the result to destination. The operands may be º words or bytes. º º OR Instruction Logic º Destination Source Result º 0 0 0 º 0 1 1 º 1 0 1 º 1 1 1 º º OR sets each bit of the result to 1 if either or both of the º corresponding bits of the operands are 1. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 3 - 2 OR CH,DL º register, memory 9(13) + EA 1 2-4 OR BX, MEM_OR_Y º memory, register 16(24) + EA 2 2-4 OR MEM_OR_Y, BX º accumulator, immediate 4 - 2-3 OR AL,01110110b º register,immediate 4 - 3-4 OR CX,00FFh º memory, immediate 17(25) + EA 2 3-6 OR MEM_WORD,76h ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: IN º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºOUT Output to Port Flags: not altered º ºOUT port,accumulator º º Logic: (port) <- accumulator º º OUT transfers a byte or a word from AL or AX to the specified port. º The port may be specified with an immediate byte constant (allowing º access to ports 0 through 255) or with a word value in DX (allowing º access to ports 0 through 65,535). º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º immed8, accumulator 10(14) 1 2 OUT 254,AX º DX, accumulator 8(12) 1 1 OUT DX,AL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Note: It is advised that hardware not use I/O ports F8h º through FFh, since these are reserved for º controlling the math coprocessor and future º processor extensions. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: PUSH POPF MOV XCHG XLAT EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºPOP POP a Word from the Stack Flags: not altered º º º ºPOP destination º º º º Logic: destination <- (SP) º º SP <- SP + 2 º º º º POP transfers the word at the top of the stack to the destination º º operand, then increments SP by 2 to point to the new top of stack. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º register 12 1 1 POP CX º º seg-reg (CS illegal) 12 1 1 POP ES º º memory 25 + EA 2 2-4 POP VALUE º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: You may not use the CS register as the destination º º of a POP instruction. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: POP PUSH PUSHF LAHF SAHF º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºPOPF POP Flags from the Stack Flags: O D I T S Z A P C º º r r r r r r r r r º º Logic: flag-register <- (SP) º º SP <- SP + 2 º º º º POPF transfers the word at the top of the stack to the flags register, º º replacing the old flags, then increments SP by 2 to point to the new º º top of stack. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 12 1 1 POPF º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: POP POPF PUSHF MOV XCHG EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºPUSH Push Word onto Stack Flags: not altered º ºPUSH source º º Logic: SP <- SP - 2 º (SP) <- source º º PUSH decrements SP by 2, then copies the operand to the new top of º stack. The source of a PUSH instruction cannot be an 8-bit register. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º register 15 1 1 PUSH BX º seg-reg (CS illegal) 14 1 1 PUSH ES º memory 24 + EA 2 2-4 PUSH PARAMETERS º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: Even if the source refers to a byte in memory, a º full word is always pushed. º º The 80286 and 80386 microprocessors will push a º different value on the stack for the instruction º PUSH SP than will the 8086/8088. The 80286 and º 80386 push the value of SP before SP is incremented, º while the 8086/8088 increments SP first, then pushes º SP on the stack. Use the following code instead of º a PUSH SP in order to obtain the same results on all º microprocessors. º º PUSH BP º MOV BP, SP º XCHG BP, [BP] º º This code functions in the same manner as a PUSH SP º on the 8088/8086. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: POPF LAHF SAHF º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºPUSHF Push Flags onto Stack Flags: not altered º º º º Logic: SP <- SP - 2 º º (SP) <- flag-register º º º º PUSHF decrements SP by 2, then transfers the flags register to the new º º top of stack. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 14 1 1 PUSHF º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: ROL ROR RCR SHL SHR SAR SAL EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºRCL Rotate through Carry Left Flags: O D I T S Z A P C º * * ºRCL destination,count º º ÚÄÄÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ º ÚÄÄÄÅÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ º ³ CF ³ ij Destination ³ ÄÙ º ÀÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ º º RCL shifts the word or byte at the destination to the left by the º number of bit positions specified in the second operand, COUNT. A bit º shifted out of the left (high-order) end of the destination enters the º carry flag, and the displaced carry flag rotates around to enter the º vacated right-most bit position of the destination. This "bit º rotation" continues the number of times specified in COUNT. (Another º way of looking at this is to consider the carry flag as the highest º order bit of the word being rotated.) º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, then the Overflow Flag is set to the XOR of the top 2 º bits of the original operand. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 2 RCL CX,1 º register, CL 8 + 4/bit - 2 RCL BL,CL º memory, 1 15(23) + EA 2 2-4 RCL MULTIPLY_X_2,1 º memory, CL 20(28)+EA+4/bit 2 2-4 RCL MOVE_AROUND,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Note: COUNT is normally taken as the value in CL. If, º however, you wish to rotate only one position, º replace the second operand, CL, with the value 1, as º shown in the first example above. º º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If the COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time that an interrupt response º will be delayed waiting for the instruction to º complete. º Multiple RCLs that use 1 as the COUNT may be faster º and require less memory than a single RCL that uses º CL for COUNT. º º The overflow flag is undefined if the rotate count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: ROR RCL ROL SAR SHR SHL SAL EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºRCR Rotate through Carry Right Flags: O D I T S Z A P C º * * ºRCR destination,count º ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄ¿ º ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÅÄÄ¿ º ÀÄ ³ Destination ³Ä ³ CF ³ º ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÙ º º RCR shifts the word or byte at the destination to the right by the º number of bit positions specified in the second operand, COUNT. A bit º shifted out of the right (low-order) end of the destination enters the º carry flag, and the displaced carry flag rotates around to enter the º vacated left-most bit position of the destination. This "bit rotation" º continues the number of times specified in COUNT. (Another way of º looking at this is to consider the carry flag as the lowest order bit º of the word being rotated.) º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, the Overflow Flag is set to the XOR of the top 2 bits º of the result. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 1 RCR CX,1 º register, CL 8 + 4/bit - 2 RCR DL,CL º memory, 1 15(23) + EA 2 2-4 RCR DIVIDE_BY_2,1 º memory, CL 20(28)+EA+4/bit 2 2-4 RCR AROUND_MOVE,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to rotate only one position, º replace the second operand, CL, with the value 1, as º shown in the first example above. º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time an interrupt response will º be delayed waiting for the instruction to complete. º Multiple RCRs that use 1 as the COUNT may be faster º and require less memory than a single RCR that uses º CL for COUNT. º The overflow flag is undefined if the rotate count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: REPNE MOVS STOS CMPS SCAS LODS CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºREP Repeat Flags: not altered º ºREP string-instruction º º Logic: while CX <> 0 ;for MOVS, LODS or STOS º execute string instruction º CX <- CX - 1 º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º while CX <> 0 º execute string instruction ;for CMPS or SCAS º CX <- CX - 1 º if ZF = 0 terminate loop º º REP is a prefix that may be specified before any string instruction º (CMPS, LODS, MOVS, SCAS, and STOS). REP causes the string instruction º following it to be repeated, as long as CX does not equal 0; CX is º decremented after each execution of the string instruction. (For CMPS º and SCAS, REP will also terminate the loop if the Zero Flag is clear º after the string instruction executes.) º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 2 - 1 REP MOVS TO,FROM º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: If CX is initially 0, the REPeated instruction is º skipped entirely. º The test for CX equal to 0 is performed before the º instruction is executed. The test for the Zero Flag º clearÄÄdone only for CMPS and SCASÄÄis performed º after the instruction is executed. º REP, REPE (Repeat While Equal), and REPZ (Repeat º While Zero) are all synonyms for the same º instruction. º REPNZ (Repeat Not Zero) is similar to REP, but when º used with CMPS and SCAS, will terminate with the º Zero Flag set, rather than cleared. º REP is generally used with the MOVS (Move String) º and STOS (Store String) instructions; it can be º thought of as "repeat while not end of string." º You do not need to initialize ZF before using º repeated string instructions. º A REPeated instruction that is interrupted between º repeats will correctly resume processing upon return º from the interrupt. However, if other prefixes are º used on a single instruction (for example, segment º override or LOCK) in addition to the REP, all º prefixes except the one that immediately preceded º the string instruction will be lost. Therefore, if º you must use more than one prefix on a single º instruction, you should disable interrupts before º the instruction, and enable them afterwards. Note º that even this precaution will not prevent a non- º maskable interrupt, and that lengthy string º operations may cause large delays in interrupt º processing. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example moves 100 bytes from BUFFER1 to BUFFER2: º º CLD ;Move in the forward direction º LEA SI, BUFFER1 ;Source pointer to SI º LEA DI, BUFFER2 ; ...and destination to DI º MOV CX,100 ;REP uses CX as the counter º REP MOVSB ; ...and do it ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: REP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºREPE Repeat While Equal Flags: not altered º º º º This instruction is a synonym for REP. See the description for REP. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: REP MOVS STOS CMPS SCAS LODS CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºREPNE Repeat While not Equal Flags: not altered º ºREPNE string-instruction º º Logic: while CX <> 0 ;for MOVS, LODS or STOS º execute string instruction º CX <- CX - 1 º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º while CX <> 0 ;for CMPS or SCAS º execute string instruction º CX <- CX - 1 º if ZF <> 0 terminate loop ;This is only difference º ;between REP and REPNE º º REPNE is a prefix that may be specified before any string instruction º (CMPS, LODS, MOVS, SCAS, and STOS). REPNE causes the string º instruction following it to be repeated, as long as CX does not equal º 0; CX is decremented after each execution of the string instruction. º (For CMPS and SCAS, REP will also terminate the loop if the Zero Flag º is set after the string instruction executes. Compare this to REP, º which will terminate if the Zero Flag is clear.) º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 2 - 1 REPNE SCASB º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: If CX is initially 0, the REPeated instruction is º skipped entirely. º The test for CX equal to 0 is performed before the º instruction is executed. The test for the Zero Flag º setÄÄdone only for CMPS and SCASÄÄis performed after º the instruction is executed. º REPNE and REPNZ are synonyms for the same º instruction. º You do not need to initialize ZF before using º repeated string instructions. º A repeated instruction that is interrupted between º repeats will correctly resume processing upon return º from the interrupt. However, if other prefixes are º used on a single instruction (for example, segment º override or LOCK) in addition to the REP, all º prefixes except the one that immediately preceded º the string instruction will be lost. Therefore, if º you must use more than one prefix on a single º instruction, you should disable interrupts before º the instruction, and enable them afterwards. Note º that even this precaution will not prevent a non- º maskable interrupt, and that lengthy string º operations may cause large delays in interrupt º processing. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example will find the first byte equal to 'A' in the º 100-byte buffer at STRING. º º CLD ;Scan string in forward direction º MOV AL,'A' ;Scan for 'A' º LEA DI, STRING ;Address to start scanning at º MOV CX,100 ;Scanning 100 bytes º REPNE SCASB ; ...and scan it º DEC DI ;Back up DI to point to the 'A' º º Upon termination of the repeated SCASB instruction, CX will be equal º to zero if a byte value of 'A' was not found in STRING, and non-zero º if it was. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: REPNE º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºREPNZ Repeat While Not Zero Flags: not altered º º º º REPNZ is the same instruction as REPNE. See the description for REPNE. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: REP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºREPZ Repeat While Zero Flags: not altered º º º º This instruction is a synonym for REP. See the description for REP. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: IRET CALL JMP º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºRET Return from Procedure Flags: not altered º ºRET optional-pop-value º º Logic: POP IP º If FAR RETURN (inter-segment) º POP CS º SP <- SP + optional-pop-value (if specified) º º RET transfers control from a called procedure back to the instruction º following the CALL, by: º Popping the word at the top of the stack into IP º If the return is an intersegment return: º Popping the word now at the top of the stack into CS º Adding the optional-pop-value, if specified, to SP º º The assembler will generate an intrasegment RET if the procedure º containing the RET was designated by the programmer as NEAR, and an º intersegment RET if it was designated FAR. The optional-pop-value º specifies a value to be added to SP, which has the effect of popping º the specified number of bytes from the top of the stack. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º (intrasegment, no pop) 20 1 1 RET º (intrasegment, with pop) 24 1 3 RET 4 º (intersegment, no pop) 32 2 1 RET º (intersegment, pop) 31 2 3 RET 2 ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: RCL ROR RCR SAL SAR SHL SHR EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºROL Rotate Left Flags: O D I T S Z A P C º * * ºROL destination,count º ÚÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ º ³ CF ³ ÄÂÄÅÄDestination ³ Ä¿ º ÀÄÄÄÄÙ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ º ÀÄ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ º ROL shifts the word or byte at the destination to the left by the º number of bit positions specified in the second operand, COUNT. As º bits are transferred out the left (high-order) end of the destination, º they re-enter on the right (low-order) end. The Carry Flag is updated º to match the last bit shifted out of the left end. º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, then the Overflow Flag is set to the XOR of the top 2 º bits of the original operand. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 2 ROL DI,1 º register, CL 8 + 4/bit - 2 ROL BX,CL º memory, 1 15(23) + EA 2 2-4 ROL BYTE,1 º memory, CL 20(28)+EA+4/bit 2 2-4 ROL WORD,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to rotate only one position, º replace the second operand, CL, with the value 1, as º shown in the first example above. º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If COUNT is greater than 31, these º microprocessors will use COUNT MOD 32 to produce a º new COUNT between 0 and 31. This upper boundary º exists to limit the amount of time that an interrupt º response will be delayed waiting for the instruction º to complete. º Multiple ROLs that use 1 as the COUNT may be faster º and require less memory than a single ROL that uses º CL for COUNT. º The overflow flag is undefined when the rotate count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: RCR ROL RCL SAR SAL SHL SHR EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºROR Rotate Right Flags: O D I T S Z A P C º * * ºROR destination,count º ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄ¿ º ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ÚÄÄÄÄÄÄ¿ º ÀÄ ³ Destination ³ÄÁÄ ³ CF ³ º ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÙ º º ROR shifts the word or byte at the destination to the right by the º number of bit positions specified in the second operand, COUNT. As º bits are transferred out the right (low-order) end of the destination, º they re-enter on the left (high-order) end. The Carry Flag is updated º to match the last bit shifted out of the right end. º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, the Overflow Flag is set to the XOR of the top 2 bits º of the result. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 2 ROR BL,1 º register, CL 8 + 4/bit - 2 ROR AX,CL º memory, 1 15(23) + EA 2 2-4 ROR WORD,1 º memory, CL 20(28)+EA+4/bit 2 2-4 ROR BYTE,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to rotate by only one position, º replace the second operand, CL, with the value 1, as º shown in the first example above. º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If the COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time an interrupt response will º be delayed waiting for the instruction to complete. º Multiple RORs that use 1 as the COUNT may be faster º and require less memory than a single ROR that uses º CL for COUNT. º The overflow flag is undefined when the rotate count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: LAHF PUSHF POPF Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSAHF Store Register AH into Flags Flags: O D I T S Z A P C º º * * * * * º º Logic: Flag-reg bits <- AH bits º º S Z A P C <- 7 6 4 2 0 º º º º SAHF copies bits 7, 6, 4, 2, and 0 from the AH register into the Flags º º register, replacing the previous values of the Sign, Zero, Auxiliary º º Carry, Parity, and the Carry flags. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 4 - 1 SAHF º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: The Overflow, Direction, Interrupt, and Trap flags º º are not changed by this instruction. º º This instruction is primarily used to provide upward º º compatibility between the 8080/8085 family and the º º 8086 family. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ º See also: SHL SAR SHR RCL RCR ROL ROR EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSAL Shift Arithmetic Left Flags: O D I T S Z A P C º * * * ? * * ºSAL destination,count º ÚÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ º ³ CF ³ Äij Destination ³ ÄÄ 0 º ÀÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ º º SAL shifts the word or byte at the destination to the left by the º number of bit positions specified in the second operand, COUNT. As º bits are transferred out the left (high-order) end of the destination, º zeroes are shifted in the right (low-order) end. The Carry Flag is º updated to match the last bit shifted out of the left end. º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, the Overflow Flag is cleared if the top 2 bits of the º original operand were the same, otherwise the Overflow Flag is set. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 2 SAL AL,1 º register, CL 8 + 4/bit - 2 SAL SI,CL º memory, 1 15(23) + EA 2 2-4 SAL WORD,1 º memory, CL 20(28)+EA+4/bit 2 2-4 SAL BYTE,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to shift only one position, º replace the second operand, CL, with the value 1, as º shown in the first example above. º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If the COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time an interrupt response will º be delayed waiting for the instruction to complete. º Multiple SALs that use 1 as the COUNT may be faster º and require less memory than a single SAL that uses º CL for COUNT. º SHL, Shift Logical Left, is the same instruction; º SHL is a synonym for SAL. º The overflow flag is undefined when the shift count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SHR SAL SHL RCR RCL ROR ROL EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSAR Shift Arithmetic Right Flags: O D I T S Z A P C º * * * ? * * ºSAR destination,count º ÚÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄ¿ º ³ SF ³ÄÄ ³ Destination ³ÄÄ ³ CF ³ º ÀÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÙ º º SAR shifts the word or byte in destination to the right by the number º of bit positions specified in the second operand, COUNT. As bits are º transferred out the right (low-order) end of the destination, bits º equal to the original sign bit are shifted into the left (high-order) º end, thereby preserving the sign bit. The Carry Flag is set equal to º the last bit shifted out of the right end. º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, the Overflow flag is cleared. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 2 SAR DX,1 º register, CL 8 + 4/bit - 2 SAR DI,CL º memory, 1 15(23) + EA 2 2-4 SAR N_BLOCKS,1 º memory, CL 20(28)+EA+4/bit 2 2-4 SAR N_BLOCKS,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to shift only one position, º replace the second operand, CL, with the value 1, as º shown in the first example above. º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If the COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time an interrupt response will º be delayed waiting for the instruction to complete. º Multiple SARs that use 1 as the COUNT may be faster º and require less memory than a single SAR that uses º CL for COUNT. º The overflow flag is undefined when the shift count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SUB DEC NEG AAS DAS EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSBB Subtract with Borrow Flags: O D I T S Z A P C º * * * * * * ºSBB destination,source º º Logic: destination <- destination - source - CF º º SBB subtracts the source from the destination, subtracts 1 from that º result if the Carry Flag is set, and stores the result in destination. º The operands may be bytes or words, and both may be signed or unsigned º binary numbers. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 3 - 2 SBB DX,AX º register, memory 9(13) + EA 1 2-4 SBB DX,FEE º memory, register 16(24) + EA 2 2-4 SBB SIGH,SI º accumulator, immediate 4 - 2-3 SBB AX,8 º register, immediate 4 - 3-4 SBB BH,4 º memory, immediate 17(25) + EA 2 3-6 SBB TOTAL,10 º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: SBB is useful for subtracting numbers that are º larger than 16 bits, since it subtracts a borrow (in º the carry flag) from a previous operation. º º You may subtract a byte-length immediate value from º a destination which is a word; in this case, the º byte is sign-extended to 16 bits before the º subtraction. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SCASB SCASW CMP CMPS REP CLD STD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSCAS Scan String (Byte or Word) Flags: O D I T S Z A P C º * * * * * * ºSCAS destination-string º º Logic: CMP Accumulator, (ES:DI) ;Sets flags only º if DF = 0 º DI <- DI + n ;n = 1 for byte, 2 for word º else º DI <- DI - n º º This instruction compares the accumulator (AL or AX) to the byte or º word pointed to by ES:DI. SCAS sets the flags according to the results º of the comparison; the operands themselves are not altered. After the º comparison, DI is incremented (if the direction flag is cleared) or º decremented (if the direction flag is set), in preparation for º comparing the next element of the string. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º dest-str 15(19) 1 1 SCAS WORD_TABLE º (repeat) dest-str 9 + 15(19)/rep 1/rep 1 REPNE SCAS BYTE_TABLE º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: This instruction is always translated by the º assembler into either SCASB, Scan String Byte, or º SCASW, Scan String Word, depending upon whether º destination-string refers to a string of bytes or º words. In either case, however, you must explicitly º load the DI register with the offset of the string. º º SCAS is useful for searching a block for a given º byte or word value. Use CMPS, Compare String, if you º wish to compare two strings (or blocks) in memory, º element by element. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Assuming the definition: º º LOST_A DB 100 DUP(?) º º (repeat) dest-str 9 + 15(19)/rep 1/rep 1 REPNE SCAS BYTE_TABLE º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: This instruction is always translated by the º assembler into either SCASB, Scan String Byte, or º SCASW, Scan String Word, depending upon whether º destination-string refers to a string of bytes or º words. In either case, however, you must explicitly º load the DI register with the offset of the string. º º SCAS is useful for searching a block for a given º byte or word value. Use CMPS, Compare String, if you º wish to compare two strings (or blocks) in memory, º element by element. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Assuming the definition: º º LOST_A DB 100 DUP(?) º º the following example searches the 100-byte block starting at LOST_A º for the character 'A' (65 decimal). º º MOV AX, DS º MOV ES, AX ;SCAS uses ES:DI, so copy DS to ES º CLD ;Scan in the forward direction º MOV AL, 'A' ;Searching for the lost 'A' º MOV CX,100 ;Scanning 100 bytes (CX is used by REPNE) º LEA DI, LOST_A ;Starting address to DI º REPNE SCAS LOST_A ; ...and scan it. º JE FOUND ;The Zero Flag will be set if we found º ; a match. º NOTFOUND: . ;If we get here, no match was found º . º . º FOUND: DEC DI ;Back up DI so it points to the first º . ; matching 'A' º . º º Upon exit from the REPNE SCAS loop, the Zero Flag will be set if a º match was found, and cleared otherwise. If a match was found, DI will º be pointing one byte past the match location; the DEC DI at FOUND º takes care of this problem. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SCAS SCASW CMPS REP CLD STD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSCASB Scan String Byte Flags: O D I T S Z A P C º * * * * * * ºSCASB º Logic: CMP AL, (ES:DI) ; Sets flags only º if DF = 0 º DI <- DI + 1 º else º DI <- DI - 1 º º This instruction compares two bytes by subtracting the destination º byte, pointed to by ES:DI, from AL. SCASB sets the flags according to º the results of the comparison. The operands themselves are not º altered. After the comparison, DI is incremented (if the direction º flag is cleared) or decremented (if the direction flag is set), in º preparation for comparing the next byte. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 15 1 1 SCASB º (repeat) 9 + 15/rep 1/rep 1 REPNE SCASB º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: SCAS is useful for searching a block for a given º byte or word value. Use CMPS, Compare String, if you º wish to compare two strings (or blocks) in memory, º element by element. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example searches the 100-byte block starting at LOST_A º for the character 'A' (65 decimal). º º MOV AX, DS º MOV ES, AX ;SCAS uses ES:DI, so copy DS to ES º CLD ;Scan in the forward direction º MOV AL, 'A' ;Searching for the lost 'A' º MOV CX,100 ;Scanning 100 bytes (CX is used by REPNE) º LEA DI, LOST_A ;Starting address to DI º REPNE SCASB ; ...and scan it. º JE FOUND ;The Zero Flag will be set if we found º ; a match. º NOTFOUND: . ;If we get here, no match was found º . º . º FOUND: DEC DI ;Back up DI so it points to the first º . ; matching 'A' º . º Upon exit from the REPNE SCASB loop, the Zero Flag will be set if a º match was found, and cleared otherwise. If a match was found, DI will º be pointing one byte past the match location; the DEC DI at FOUND º takes care of this problem. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SCAS SCASB CMPS REP CLD STD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSCASW Scan String Word Flags: O D I T S Z A P C º * * * * * * ºSCASW º º Logic: CMP AX, (ES:DI) ; Sets flags only º if DF = 0 º DI <- DI + 2 º else º DI <- DI - 2 º º This instruction compares two words by subtracting the destination º word, pointed to by ES:DI, from AX. SCASW sets the flags according to º the results of the comparison. The operands themselves are not º altered. After the comparison, DI is incremented (if the direction º flag is cleared) or decremented (if the direction flag is set), in º preparation for comparing the next word. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 19 1 1 SCASW º (repeat) 9 + 19/rep 1/rep 1 REPNE SCASW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: SCAS is useful for searching a block for a given º byte or word value. Use CMPS, Compare String, if you º wish to compare two strings (or blocks) in memory, º element by element. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º The following example searches the 100-byte block starting at LOST_A º for the character 'A' (65 decimal). º º MOV AX, DS º MOV ES, AX ;SCAS uses ES:DI, so copy DS to ES º CLD ;Scan in the forward direction º MOV AL, 'A' ;Searching for the lost 'A' º MOV CX,50 ;Scanning 50 words (CX is used by REPNE) º LEA DI, LOST_A ;Starting address to DI º REPNE SCASW ; ...and scan it. º JE FOUND ;The Zero Flag will be set if we found º ; a match. º NOTFOUND: . ;If we get here, no match was found º . º . º FOUND: DEC DI ;Back up DI so it points to the first º DEC DI ; matching 'A' º . º . º Upon exit from the REPNE SCASW loop, the Zero Flag will be set if a º match was found, and cleared otherwise. If a match was found, DI will º be pointing two bytes (one word) past the match location; the DEC DI º pair at FOUND takes care of this problem. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SAL SHR SAR RCL RCR ROL ROR EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSHL Shift Logical Left Flags: O D I T S Z A P C º * * * ? * * ºSHL destination,count º ÚÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ º ³ CF ³ Äij Destination ³ ÄÄ 0 º ÀÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ º SHL is the same instruction as SAL, Shift Arithmetic Left. SHL shifts º the word or byte at the destination to the left by the number of bit º positions specified in the second operand, COUNT. As bits are º transferred out the left (high-order) end of the destination, zeroes º are shifted in the right (low-order) end. The Carry Flag is updated to º match the last bit shifted out of the left end. º º If COUNT is not equal to 1, the Overflow flag is undefined. If COUNT º is equal to 1, the Overflow Flag is cleared if the top 2 bits of the º original operand were the same, otherwise the Overflow Flag is set. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, 1 2 - 2 SHL AL,1 º register, CL 8 + 4/bit - 2 SHL SI,CL º memory, 1 15(23) + EA 2 2-4 SHL WORD,1 º memory, CL 20(28)+EA+4/bit 2 2-4 SHL BYTE,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to shift only one position, º replace the second operand, CL, with the value 1, as º shown in the first example below. º º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If the COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time an interrupt response will º be delayed waiting for the instruction to complete. º º Multiple SHLs that use 1 as the COUNT may be faster º and require less memory than a single SHL that uses º CL for COUNT. º º The overflow flag is undefined when the shift count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SAR SHL SAL RCR RCL ROR ROL EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSHR Shift Logical Right Flags: O D I T S Z A P C º * * * ? * * ºSHR destination,count º ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄ¿ º 0 ÄÄ ³ Destination ³ÄÄ ³ CF ³ º ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÙ º º SAR shifts the bits in destination to the right by the number of º positions specified in the count operand (or in CL, if no count º operand is included). 0s are shifted in on the left. If the sign bit º retains its original value, the Overflow Flag is cleared; it is set if º the sign changes. The Carry Flag is updated to reflect the last bit º shifted. º º If COUNT is not equal to 1, the Overflow flag is undefined, otherwise º the Overflow Flag is set to the high-order bit of the original º operand. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º register, 1 2 - 2 SHR SI,1 º register, CL 8 + 4/bit - 2 SHR SI,CL º memory, 1 15 + EA 2 2-4 SHR ID_BYTE[SI][BX],1 º memory, CL 20 + EA + 4/bit 2 2-4 SHR INPUT_WORD,CL º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: COUNT is normally taken as the value in CL. If, º however, you wish to shift only one position, º replace the second operand, CL, with the value 1, as º shown in the first example below. º º The 80286 and 80386 microprocessors limit the COUNT º value to 31. If the COUNT is greater than 31, these º microprocessors use COUNT MOD 32 to produce a new º COUNT between 0 and 31. This upper bound exists to º limit the amount of time an interrupt response will º be delayed waiting for the instruction to complete. º º Multiple SHRs that use 1 as the COUNT may be faster º and require less memory than a single SHR that uses º CL for COUNT. º The overflow flag is undefined when the shift count º is greater than 1. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CLC CMC STD CLD STI CLI Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSTC Set Carry Flag Flags: O D I T S Z A P C º º 1 º º Logic: CF <- 1 º º º º STC sets the Carry Flag. No other flags are affected. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 STC º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CLD STC CLC CMC STI CLI Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSTD Set Direction Flag Flags: O D I T S Z A P C º º 1 º º Logic: DF <- 1 (Decrement in string instructions) º º º º STD sets the Direction Flag. No other flags are affected. Setting the º º direction flag causes string operations to decrement SI and DI. º º º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 STD º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CLI STC CLC CMC STD CLD Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSTI Set Interrupt Enable Flag Flags: O D I T S Z A P C º º 1 º º Logic: IF <- 1 º º º º STI sets the Interrupt Enable Flag, permitting the processor to º º recognize maskable interrupts. No other flags are affected. (Non- º º maskable interrupts are recognized no matter what the state of the º º interrupt enable flag.) º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 2 - 1 STI º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º º º Notes: A pending interrupt will not be recognized until º º after the instruction following the STI executes. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STOSB STOSW CMPS LODS MOVS SCAS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSTOS Store String (Byte or Word) Flags: not altered º ºSTOS destination-string º º Logic: (ES:DI) <- Accumulator º if DF = 0 º DI <- DI + n ; n = 1 for byte, 2 for word scan º else º DI <- DI - n º º STOS copies the value (byte or word) in AL or AX into the location º pointed to by ES:DI. DI is then incremented (if the direction flag is º cleared) or decremented (if the direction flag is set), in preparation º for storing the accumulator in the next location. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º dest-string 11(15) 1 1 STOS WORD_ARRAY º (repeat) dest-string 9 + 10(14)/rep 1/rep 1 REP STOS BYTE_ARRAY º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: This instruction is always translated by the º assembler into either STOSB, Store String Byte, or º STOSW, Store String Word, depending upon whether º destination-string refers to a string of bytes or º words. In either case, however, you must explicitly º load the DI register with the offset of the string. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Example ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º When used in conjunction with the REP prefixes, the Store String º instructions are useful for initializing a block of memory. For º example, the following code would initialize the 100-byte memory block º at BUFFER to 0: º º MOV AL,0 ;The value to initialize BUFFER to º LEA DI,BUFFER ;Starting location of BUFFER º MOV CX,100 ;Size of BUFFER º CLD ;Let's move in forward direction º REP STOS BUFFER ;Compare this line to example for STOSB ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STOS STOSW CMPS LODS MOVS SCAS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSTOSB Store String Byte Flags: not altered º ºSTOSB º Logic: (ES:DI) <- AL º if DF = 0 º DI <- DI + 1 º else º DI <- DI - 1 º º STOSB copies the value in AL into the location pointed to by ES:DI. DI º is then incremented (if the direction flag is cleared) or decremented º (if the direction flag is set), in preparation for storing AL in the º next location. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 11 1 1 STOSB º (repeat) 9 + 10/rep 1/rep 1 REP STOSB º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º When used in conjunction with the REP prefixes, the Store String º instructions are useful for initializing a block of memory. For º example, the following code would initialize the 100-byte memory block º at BUFFER to 0: º º MOV AL,0 ;The value to initialize BUFFER to º LEA DI,BUFFER ;Starting location of BUFFER º MOV CX,100 ;Size of BUFFER º CLD ;Let's move in forward direction º REP STOSB ;Compare this line to example for STOS ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: STOS STOSB CMPS LODS MOVS SCAS REP CLD STD º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSTOSW Store String Word Flags: not altered º º Logic: (ES:DI) <- AX º if DF = 0 º DI <- DI + 2 º else º DI <- DI - 2 º º STOSW copies the value in AX into the location pointed to by ES:DI. DI º is then incremented (if the direction flag is cleared) or decremented º (if the direction flag is set), in preparation for storing AX in the º next location. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º - 15 1 1 STOSW º (repeat) 9 + 14/rep 1/rep 1 REP STOSW º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º When used in conjunction with the REP prefixes, the Store String º instructions are useful for initializing a block of memory. For º example, the following code would initialize the 100-byte memory block º at BUFFER to 0: º º MOV AX,0 ;The value to initialize BUFFER to º LEA DI,BUFFER ;Starting location of BUFFER º MOV CX,50 ;Size of BUFFER, in words º CLD ;Let's move in forward direction º REP STOSW ;Compare this line to example for STOS ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: SBB DEC NEG CMP AAS DAS EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºSUB Subtract Flags: O D I T S Z A P C º * * * * * * ºSUB destination,source º º Logic: destination <- destination - source º º SUB subtracts the source operand from the destination operand and º stores the result in destination. Both operands may be bytes or words, º and both may signed or unsigned binary numbers. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 3 - 2 SUB DX,BX º register, memory 9(13) + EA 1 2-4 SUB DX,TOTAL º memory, register 16(24) + EA 2 2-4 SUB RATE,CL º accumulator, immediate 4 - 2-3 SUB AH,25 º register, immediate 4 - 3-4 SUB DX,5280 º memory, immediate 17(25) + EA 2 3-6 SUB RESULT,1032 º º Notes: You may wish to use SBB if you need to subtract º numbers that are larger than 16 bits, since SBB º subtracts a borrow from a previous operation. º You may subtract a byte-length immediate value from º a destination which is a word; in this case, the º byte is sign-extended to 16 bits before the º subtraction. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: CMP AND NOT OR XOR EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºTEST Test Flags: O D I T S Z A P C º 0 * * ? * 0 ºTEST destination,source º º Logic: (destination AND source) ; Set flags only º CF <- 0 º OF <- 0 º º TEST performs a logical AND on its two operands and updates the flags. º Neither the destination nor source is changed. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º byte(word) º register, register 3 - 2 TEST SI,DX º register, memory 9(13) + EA 1 2-4 TEST SI,MASK º accumulator, immediate 4 - 2-3 TEST AL,00000100b º register, immediate 5 - 3-4 TEST CX,1234 º memory, immediate 11 + EA - 3-6 TEST PARAM,1F1Fh º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º TEST is useful for examining the status of individual bits. For º example, the following section of code will transfer control to º ONE_FIVE_OFF if both bits one and five of register AL are cleared. The º status of all other bits will be ignored. º º TEST AL,00100010b ;Mask out all bits except 1 and 5 º JZ ONE_FIVE_OFF ;If either was set, result was not 0 º NOT_BOTH: . ;One or both bits was set º º ONE_FIVE_OFF: ; Bits 1 and 5 were off º . º . ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: HLT ESC LOCK º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºWAIT Wait Flags: not altered º º º º Logic: None º º º º WAIT causes the processor to enter a wait state. The processor will º º remain inactive until the TEST input on the microprocessor is driven º º active. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º no operands 3 + 5n - 1 WAIT º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: This instruction is used to synchronize external º º hardware, such as a coprocessor. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: MOV PUSH POP XLAT EA º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºXCHG Exchange Registers Flags: not altered º º º ºXCHG destination,source º º º º Logic: destination <--> source º º º º XCHG switches the contents of its operands, which may be either bytes º º or words. º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Operands Clocks Transfers Bytes Example º º byte(word) º º accumulator, reg16 3 - 1 XCHG AX,SI º º memory, register 17(25) + EA 2 2-4 LOCK XCHG SEMPHOR, DXº º register, register 4 - 2 XCHG CL,DL º º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º º Notes: Used in conjunction with the LOCK prefix, this º º instruction is particularly useful when implementing º º semaphores to control shared resources. º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ºXLAT Translate Flags: not altered º ºXLAT translate-table º º Logic: AL <- (BX + AL) º º XLAT translates bytes via a table lookup. A pointer to a 256-byte º translation table is loaded into BX. The byte to be translated is º loaded into AL; it serves as an index (ie, offset) into the º translation table. After the XLAT instruction is executed, the byte in º AL is replaced by the byte located AL bytes from the beginning of the º translate-table. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º translate-table 11 1 1 XLAT SINE_TABLE º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Notes: Translate-table can be less than 256 bytes. º º The operand, translate-table, is optional since a º pointer to the table must be loaded into BX before º the instruction is executed. º º The following example translates a decimal value (0 to 15) to the º corresponding single hexadecimal digit. º º lea bx, hex_table ;pointer to table into BX º mov al, decimal_digit ;digit to be translated to AL º xlat hex_table ;translate the value in AL º . ;AL now contains ASCII hex digit º . º hex_table db '0123456789ABCDEF' ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º See also: OR AND NOT EA Flags º ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ ºXOR Exclusive OR Flags: O D I T S Z A P C º 0 * * * * 0 ºXOR destination,source º Logic: destination <- destination XOR source º º XOR performs a bit-by-bit "exclusive or" on its two operands, and º returns the result in the destination operand. The operands may be º bytes or words. º XOR Instruction Logic º Destination Source Result º 0 0 0 º 0 1 1 º 1 0 1 º 1 1 0 º º XOR sets each bit of the result to 1 only one of the corresponding º bits is set to one. º ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ º Operands Clocks Transfers Bytes Example º register, register 3 - 2 XOR CX,BX º register, memory 9(13) + EA 1 2-4 XOR CL,MASK_BYTE º memory, register 16(24) + EA 2 2-4 XOR ALPHA[SI],DX º accumulator, immediate 4 - 2-3 XOR AL,01000001b º register, immediate 4 - 3-4 XOR SI,00C2h º memory, immediate 17(25) + EA 2 3-6 XOR RETURN_CODE,0D2h ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ