我怎样才能乘用x86汇编语言两个64位数字? [英] How can I multiply two 64-bit numbers using x86 assembly language?

查看:299
本文介绍了我怎样才能乘用x86汇编语言两个64位数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会去...


  • 相乘两个64位数字

  • multiplying two 64-bit numbers

相乘两个16位十六进制数

multiplying two 16-digit hexadecimal numbers

...使用汇编语言。

...using Assembly Language.

我只允许使用寄存器%EAX,EBX%,ECX%,%EDX,堆栈。

I'm only allowed to use registers %eax, %ebx, %ecx, %edx, and the stack.

编辑:哦,我使用ATT语法在x86结果
EDIT2:不允许反编译成汇编...

Oh, I'm using ATT Syntax on the x86
Not allowed to decompile into assembly...

推荐答案

使用什么也许应该是你的课本,兰德尔海德的汇编语言艺术。

Use what should probably be your course textbook, Randall Hyde's "The Art of Assembly Language".

请参阅4.2.4 - 扩展precision乘法

虽然一个8×8,16×16或32x32乘法通常是足够的,有些时候你可能要乘以较大的值在一起。您将使用以延长precision乘法x86的单操作数MUL和IMUL指令。

Although an 8x8, 16x16, or 32x32 multiply is usually sufficient, there are times when you may want to multiply larger values together. You will use the x86 single operand MUL and IMUL instructions for extended precision multiplication ..

也许最重要的是要记住的当执行扩展precision乘法,还必须进行多precision另外在同一时间的。添加了所有的部分产品需要一些补充,将产生的结果。下面的清单演示了在32位处理器将两个64位值的正确方法。

Probably the most important thing to remember when performing an extended precision multiplication is that you must also perform a multiple precision addition at the same time. Adding up all the partial products requires several additions that will produce the result. The following listing demonstrates the proper way to multiply two 64 bit values on a 32 bit processor ..

(见链接全装配房源和插图。)

(See the link for full assembly listing and illustrations.)

这篇关于我怎样才能乘用x86汇编语言两个64位数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆