ia-32_instruction-set-ref_a-m

Mode exceptions none virtual 8086 mode exceptions

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r is the implied source and destination operand for this instruction. The AAM instruction is only useful when it follows an MUL instruction that multiplies (binary multiplication) two unpacked BCD values and stores a word result in the AX register. The AAM instruction then adjusts the contents of the AX register to contain the correct 2-digit unpacked (base 10) BCD result. The generalized version of this instruction allows adjustment of the contents of the AX to create two unpacked digits of any number base (see the "Operation" section below). Here, the imm8 byte is set to the selected number base (for example, 08H for octal, 0AH for decimal, or 0CH for base 12 numbers). The AAM mnemonic is interpreted by all assemblers to mean adjust to ASCII (base 10) values. To adjust to values in another number base, the instruction must be hand coded in machine code (D4 imm8). This instruction executes as described in compatibility mode and legacy mode. It is not valid in 64-bit mode. Operation IF 64-Bit Mode THEN #UD; ELSE tempAL AL; AH tempAL / imm8; (* imm8 is set to 0AH for the AAM mnemonic *) AL tempAL MOD imm8; FI; The immediate value (imm8) is taken from the second byte of the instruction. Flags Affected The SF, ZF, and PF flags are set according to the resulting binary value in the AL register. The OF, AF, and CF flags are undefined. Vol. 2 3-23 INSTRUCTION SET REFERENCE, A-M Protected Mode Exceptions #DE If an immediate value of 0 is used. Real-Address Mode Exceptions Same exception as in Protected Mode. Virtual-8086 Mode Exceptions Same exception as in Protected Mode. Compatibility Mode Exceptions Same exception as in Protected Mode. 64-Bit Mode Exceptions #UD If in 64-bit mode. 3-24 Vol. 2 INSTRUCTION SET REFERENCE, A-M AAS--ASCII Adjust AL After Subtraction Opcode 3F Instruction AAS 64-Bit Mode Invalid Compat/ Leg Mode Valid Description ASCII adjust AL after subtraction. Description Adjusts the result of the subtraction of two unpacked BCD values to create a unpacked BCD result. The AL register is the implied source and destination operand for this instruction. The AAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one unpacked BCD value from another and stores a byte result in the AL register. The AAA instruction then adjusts the contents of the AL register to contain the correct 1-digit unpacked BCD result. If the subtraction produced a decimal carry, the AH register decrements by 1, and the CF and AF flags are set. If no decimal carry occurred, the CF and AF flags are cleared, and the AH register is unchanged. In either case, the AL register is left with its top nibble set to 0. This instruction executes as described in compatibility mode and legacy mode. It is not valid in 64-bit mode. Operation IF 64-bit mode THEN #UD; ELSE IF ((AL AND 0FH) > 9) or (AF = 1) THEN AL AL 6; AH AH 1; AF 1; CF 1; AL AL AND 0FH; ELSE CF 0; AF 0; AL AL AND 0FH; FI; FI; Flags Affected The AF and CF flags are...
View Full Document

This note was uploaded on 10/01/2013 for the course CPE 103 taught by Professor Watlins during the Winter '11 term at Mississippi State.

Ask a homework question - tutors are online