x86汇编(MASM)

编程入门 行业动态 更新时间:2024-10-26 22:23:50
本文介绍了x86汇编(MASM) - 一个64位整数的平方根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在x86汇编语言(MASM32),其中涉及计算(64位)整数的平方根编码一个简单的测试素性程序为Windows。我的问题是:有没有获得平方根什么简单的办法?我应该使用ADD / SUB的组合/ DIV / MUL指令?

I'm coding a simple primality tester program for Windows in x86 assembly language (MASM32), which involves calculating a square root of a (64-bit) integer. My question is: Is there any simple way for obtaining the square root? Should I use some combination of ADD/SUB/DIV/MUL instructions?

我发现了一些 的信息C语言,但我只是想知道如果我在这里失去了一些东西?

I found some information on how this could be achieved in C language, but I'm just wondering if I'm missing something here?

推荐答案

我觉得最简单的方法就是使用FPU指令 FSQRT 是这样的:

I think the simplest way is to use the FPU instruction fsqrt like this:

.data? int64 dq ? squareRoot dd ? .code fild int64 ;load the integer to ST(0) fsqrt ;compute square root and store to ST(0) fistp squareRoot ;store the result in memory (as a 32-bit integer) and pop ST(0)

更多推荐

x86汇编(MASM)

本文发布于:2023-11-29 23:40:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647983.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MASM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!