我该如何将 ASM 转换为 PHP?
有一个程序我想多了解一点,但大部分是在 ASM 中。 MatrixMultiply
参考页面为 MatrixMultiply cortstratton.org/articles/OptimizingForSSE.php" rel="nofollow noreferrer">此处。
我了解C++,但ASM部分有点模糊。有人可以解释一下吗?
There is a program I would like to understand a bit more of, but most of it is in ASM. MatrixMultiply
The reference page is here.
I understand C++, but the ASM part is a bit vague. Can someone explain?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该程序使用SIMD(即SSE)指令来优化矩阵乘法。考虑将其转换为 PHP 的方法是没有意义的,因为它是一种解释性语言 - 你无法以这种方式访问 CPU,哎呀,PHP 可能会在甚至不提供这些指令的 CPU 上运行。
如果您想在 PHP 中执行此操作,您可以创建一个简单的、非优化的矩阵乘法例程,也可以开发一个扩展。不过,在后一种情况下,我建议使用规范的 BLAS 实现之一,而不是使用网络上的一些随机代码片段。
请参阅http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms
This program uses SIMD (i.e. SSE) instructions to optimize matrix multiplication. There is no sense in thinking of a way to convert this to PHP, as it is an interpreted language - you don't have access to the CPU in that way, heck, PHP might run on a CPU who does not even provide these instructions.
If you want to do this in PHP, you can either create a simple, non-optimized routine for matrix multiplication or develop an extension. In the latter case, I'd suggest using one of the canonical BLAS implementations, though, instead of some random code snippet from the web.
See http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms
您要查找的搜索关键字是
decompiler
。 AFAIK,您可能无法将 x86 程序集转换为 PHP 反编译器,因为可能没有人发现需要它。如果您的目的是了解汇编代码。 C的反编译器有很多,读C代码就可以理解了。
The search keyword you are looking for is
decompiler
. AFAIK, You may not be able to convert x86 assembly to PHP decompiler because no one might not found need for it.If your purpose is to understand the assembly code. There are lot of decompilers for C. You can understand reading the C code.
PHPMath 上有 Java 的 JAMA 标准矩阵类的 PHP 端口,它提供了一套用于 martix 加法、减法、乘法、除法、变换等的方法。它是用 PHP4 编写的,但不需要做很多工作就可以转换为 PHP5。
虽然没有直接回答您有关 ASM 到 PHP 的问题,但为您提供现成的 PHP MatrixMultiply 可能会很有用
There is a PHP port of the JAMA standard matrix class for Java over on PHPMath, which provides a suite of methods for martix addition, subtraction, multiplication, division, transform, etc. It's coded in PHP4, but doesn't take a lot of work to convert to PHP5.
While not directly answering your question about ASM to PHP, it may be useful to give you a ready-built PHP MatrixMultiply