aaa和daa指令是什么意思,我看了半天都看不懂,它们和BCD有什么关系?

seanerwu 2002-04-29 11:13:17
aaa和daa指令是什么意思,我看了半天都看不懂,它们和BCD有什么关系?
...全文
1098 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandwish2000 2002-04-30
  • 打赏
  • 举报
回复
是加法的bcd调整命令.
aaa
1 如果al中的低4位在0-9之间,且af为0,则转3
2 如果al中的低4位在a-f之间或af为1,则al=(al)+6;ah=(ah)+1;af=1
3 清除al的高4位
4 af的值送cf位
daa
1 如果al的低4位在a-f之间或af为1,则al=(al)+6,af=1
2 如果al中的低4位在a-f之间或cf为1,则al=(al)+60h,cf=1
awinder 2002-04-29
  • 打赏
  • 举报
回复
AAA - Ascii Adjust for Addition
37 AAA ASCII adjust AL after addition

Description
Adjusts the sum of two unpacked BCD values to create an unpacked BCD result. The AL register is the implied source and destination operand for this instruction. The AAA instruction is only useful when it follows an ADD instruction that adds (binary addition) two unpacked BCD values 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 addition produces a decimal carry, the AH register is incremented by 1, and the CF and AF flags are set. If there was no decimal carry, the CF and AF flags are cleared and the AH register is unchanged. In either case, bits 4 through 7 of the AL register are cleared to 0.

Operands Bytes Clocks
1 3 NP

Flags
The AF and CF flags are set to 1 if the adjustment results in a decimal carry; otherwise they are cleared to 0. The OF, SF, ZF, and PF flags are undefined.


AAD - Ascii Adjust AX Before Division
D5 0A AAD ASCII adjust AX before division
D5 ib (No mnemonic) Adjust AX before division to number base imm8

Description
Adjusts two unpacked BCD digits (the least-significant digit in the AL register and the most-significant digit in the AH register) so that a division operation performed on the result will yield a correct unpacked BCD value. The AAD instruction is only useful when it precedes a DIV instruction that divides (binary division) the adjusted value in the AX register by an unpacked BCD value.

The AAD instruction sets the value in the AL register to (AL + (10 * AH)), and then clears the AH register to 00H. The value in the AX register is then equal to the binary equivalent of the original unpacked two-digit (base 10) number in registers AH and AL.

The generalized version of this instruction allows adjustment of two unpacked digits of any number base (see the "Operation" section below), by setting the imm8 byte to the selected number base (for example, 08H for octal, 0AH for decimal, or 0CH for base 12 numbers). The AAD mnemonic is interpreted by all assemblers to mean adjust ASCII (base 10) values. To adjust values in another number base, the instruction must be hand coded in machine code (D5 imm8).

Operands Bytes Clocks
2 10 NP

Flags
The SF, ZF, and PF flags are set according to the result; the OF, AF, and CF flags are undefined.
Lesily 2002-04-29
  • 打赏
  • 举报
回复
ASCII 码的加法调整 AAA

用途:AAA指令用于对两个未压缩的十进制数相加而在AL中产生的一个未压缩的十进制结果进行校正。
格式:AAA(不带操作数)
例子:AAA;after the addition

ASCII 码的除法调整 AAD

用途:在一条指令对两个未压缩的十进制操作进行除法运算之前,AAD对AL中的被除数进行调整,以便除法的结果将是一个未压缩的十进制的商。
格式:AAD(不带操作数)
例子:AAD;prior to the division

21,453

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧