x86 assembly - masm32: absolute breakdown of multiplication and division [closed]

北慕城南 提交于 2019-12-13 23:16:21

问题


I have looked all over the internet for a simple-to-understand evaluation of how to multiply and divide in masm32 assembly. My questions are:

  1. Where should I place the numbers being multiplied?

  2. Where should I place the numbers being divided?

  3. Where does the remainder go in the division?

Could someone please answer this for me?

Thanks,

Progrmr


回答1:


The answer to this question can be very easily found by looking at the proper page of the Intel 64 and IA-32 Instruction Set Reference. In this case, you're looking for the MUL and DIV instructions (in case you're operating on unsigned operands) or IMUL and IDIV instructions, which are used for signed integer multiplication and division.

So, in case you really don't feel like looking through the manual :

  1. One of the operands of the multiplication must be placed in the EAX register if you're using MUL. This is a bit more flexible if you're using the IMUL instruction, which allows you to specify the source and destination registers.
  2. The number being divided is always a 64-bit number in 32-bit mode. The high bits go into EDX, while the lower bits go into EAX.
  3. The remainder is always placed in EDX.


来源:https://stackoverflow.com/questions/10684736/x86-assembly-masm32-absolute-breakdown-of-multiplication-and-division

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