免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2402 | 回复: 2

AAD和AAM是one-byte Opcode 还是 two-byte Opcode? [复制链接]

论坛徽章:
0
发表于 2009-09-01 11:09 |显示全部楼层
看Intel的白皮书,在 Instruction formats and encodings 的 Integer instruction formats and encodings里一开头
就有AAD和AAM的Encoding,分别是 1101 0101:0000 1010 和 1101 0100:0000 1010

   但是在Intel的 OpcodeMap 里面 AAD和AAM指令都是在One-byte Opcode  的D4和D5.。。。。。。


   现在我就迷糊了,倒是AAM是One-byte code 还是 two-byte code ???

   1. 如果是它们One-byte code 是不是说我只用判断第一个字节( 1101 0101 和 1101 0100)就可以知道是AAD或是AAM?  
  2. 既然我们可以用一个字节就可以判断AAM和AAD,那那后面的一个字节的指令数据时做什么的?
  3.AAM和AAD指令编译后倒是是占一个字节还是占两个字节????



好奇怪啊。。。。。。。救救。。。

论坛徽章:
0
发表于 2009-09-01 16:07 |显示全部楼层
帮帮忙~~~~~~

论坛徽章:
0
发表于 2009-09-01 16:17 |显示全部楼层
自己找到答案了~~~~

Undocumented:  Available to all Intel x86 processors.
               Useful in production source code.
                                                              AAM
Flags:                                ASCII Adjust after Multiply
+-+-+-+-+-+-+-+-+-+                       +----------+----------+
|O|D|I|T|S|Z|A|P|C|                       | 11010100 |   DATA   |
+-+-+-+-+-+-+-+-+-+                       +----------+----------+
|0| | | |+|+|0|+|0|                       |    D4    |     IMM8 |
+-+-+-+-+-+-+-+-+-+                       +----------+----------+

AAM is shown as a two byte encoding used to divide AL by 10, putting the quotient in AH, and the remainder in AL. However, AAM is listed in the op code map as a single byte instruction. This leads one to wonder why a two-byte opcode is listed in the single-byte opcode map. In reality, the second byte is an undocumented operand to AAM. The operand is the divisor. In its documented incarnation, AAM is encoded as D4 0A. The operand 0A is the divisor. This divisor can be changed to any value between 0 and FF. Using AAM in this manner is useful -- as it extends the CPU instruction set to include a DIV IMM8 instruction that is not available from any other form of the DIV instruction. The extended form of the AAM instruction is also useful because it sets the flags register according to the results, unlike the DIV or IDIV instruction. According to Intel documentation, SF, ZF, and PF flags are set according to the result, while OF, AF, and CF are undefined. However, if AAM were used strictly as documented, then the Sign Flag (SF) could not be set under any circumstances, since anything divided by 10 will leave a remainder between 0 and 9. Obviously the remainder could never be between 128 and 255 (or -1 and -128 if you prefer) if used only as documented. Since AAM divides an 8 bit number by another 8-bit number, a carry or overflow could never occur. Therefore CF and OF always=0. Intel claims they are undefined, but my observations are consistent with my theory. Contrary to documentation, AAM will generate exceptions in real mode, protected mode, and V86 mode. AAM can only generate Exception 0 -- divide by 0. Finally, in the Pentium User's Manual, this heretofore undocumented form of AMM is described. Intel says:

"Note: imm8 has the value of the instruction's second byte. The second byte under normally assembly [sic] of this instruction will be 0A, however, explicit modification of this byte will result in the operation described above and may alter results."

This instruction exists in this form on all Intel x86 processors. See the file AAM.ASM for diagnostics source code for this instruction.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

DTCC2020中国数据库技术大会

【架构革新 高效可控】2020年12月21日-23日第十一届中国数据库技术大会将在北京隆重召开。

大会设置2大主会场,20+技术专场,将邀请超百位行业专家,重点围绕数据架构、AI与大数据、传统企业数据库实践和国产开源数据库等内容展开分享和探讨,为广大数据领域从业人士提供一场年度盛会和交流平台。

http://dtcc.it168.com


大会官网>>
  

北京盛拓优讯信息技术有限公司. 版权所有 16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122
中国互联网协会会员  联系我们:huangweiwei@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP