"A" Instructions

AC - Instruções


AAA - ASCII Adjust after Addition

See also: AAD, AAS, AAM, ADC, DAA, 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.

AC - InstruçõesÍndice


AAD - ASCII Adjust before Division

See Also: AAA, AAS, AAM, DIV, IDIV, 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.

AC - InstruçõesÍndice


AAM - ASCII Adjust after Multiply

See also: AAA, AAD, AAS, MUL, IMUL, 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.

AC - InstruçõesÍndice


AAS - ASCII Adjust after Subtraction

See Also: AAA, AAD, AAS, SUB, SBB, DAS, 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.

AC - InstruçõesÍndice


ADC - Add with Carry

See Also: ADD, INC, AAA, DAA, EA, 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
byte(word)
Transfers Bytes Example
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.

AC - InstruçõesÍndice


ADD - Addition

See Also: ADC, INC, AAA, DAA, EA, 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
byte(word)
Transfers Bytes Example
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

AC - InstruçõesÍndice


AND - Logical AND

See also: NOT, OR, XOR, EA, 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
byte(word)
Transfers Bytes Example
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

AC - InstruçõesÍndice


Última actualização: 02 Maio 2005

AC - Instruções