Assembly x86 division with DX:AX

断了今生、忘了曾经 提交于 2019-12-02 05:17:21

As you correctly note, you can't use a 32-bit number as the divisor in a 16-bit division, but since we're only interested in doing integer division that's not a problem.

There are two cases to consider (for unsigned division):

  • DX == 0: The result of C*D fits in 16 bits so we can proceed as normal using ax as the 16-bit divisor.
  • DX > 0 (DX != 0): C*D is greater than 65335 (0xFFFF) and the 16-bit unsigned division of A and that number will always be 0 and the remainder is simply A.

Or you could do as C and just assume that the result of C*D fits in 16 bit. :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!