MMX-使用恒定字节 [英] MMX - working with constant bytes

查看:99
本文介绍了MMX-使用恒定字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究某些东西,但遇到了另外两个问题.首先:

ROR64 macro a, rot
; Result := (A shl (64-rot)) xor (A shr rot);
  MOV     EAX, 64
  SUB     EAX, rot
  PSLLQ   a, EAX
  MOVQ    mm6, a
  PSRLQ   mm6, rot
  PXOR    a, mm6
endm

我一直在尝试对每个问题使用QWords进行该过程(我也可能会尝试使用DWords进行学习).我正在使用的开发机上只能访问MMX指令,因此我去了那里.问题一直在处理来自"rot"的值,因为我确定MMX ops只能通过我从MASM32得到的错误在那些寄存器上工作.但是,当我尝试将"rot"和"64-rot"放入MMX寄存器中时,会出现更多错误.我该如何解决?

我还需要将MMX寄存器添加为QWords.我在参考文献中没有看到执行此操作的指令.我是否仍需要将这些寄存器拆分为常规寄存器,或者通过FP指令将其推送?

解决方案

MMX 用于SIMD编程(通常不适合64位操作).

请参见维基百科 .. "MMX指令集的主要用法基于打包数据类型的概念,这意味着与其使用整个寄存器来代替单个64位整数,两个32位整数,四个16位整数,位整数或八个8位整数可以同时处理."

如今,由于SSEx技术,它已过时. 抱歉,但规范中没有类似PADDQ的指令(请看 PADDx ).

Shift指令仅接受8位位移或其他MMX寄存器来容纳转变.这意味着您不能使用eax之类的寄存器来完成这项工作.可以尝试,但有时希望与现实世界无关.

顺便说一句,请仔细看一下您发布的宏.无论如何,我认为这似乎是不正确的.请考虑您要执行的操作顺序和期望的结果.

由于您使用的宏会在您使用的任何时间发出代码,因此您可以尝试(未经测试):

TEST macro a, rot
; Result := (A shl (64-rot)) xor (A shr rot);
  MOVQ    mm6, a
  PSLLQ   a, 64-rot
  PSRLQ   mm6, rot
  PXOR    a, mm6
endm

I've been working on something and run into another couple of problems. First off:

ROR64 macro a, rot
; Result := (A shl (64-rot)) xor (A shr rot);
  MOV     EAX, 64
  SUB     EAX, rot
  PSLLQ   a, EAX
  MOVQ    mm6, a
  PSRLQ   mm6, rot
  PXOR    a, mm6
endm

I've been attempting the process using QWords per the last question (I'll probably attempt it with DWords to learn, too). All I have access to on the dev machine I'm using is MMX instructions, so I've been going there. The problem has been handling the values that come from "rot", since I've determined the MMX ops only work on those registers via the errors I get from MASM32. But when I attempt to put "rot" and "64-rot" into a MMX register, I get more errors. How do I resolve this?

Also I will need to be adding MMX registers as QWords. I do not see an instruction in the references to do this. Will I need to be splitting those up into the regular registers anyway or pushing them through the FP instructions?

解决方案

MMX is meant for SIMD programming (it was not meant for 64 Bit operation in general).

See wikipedia .. "The main usage of the MMX instruction set is based on the concept of packed data types, which means that instead of using the whole register for a single 64-bit integer, two 32-bit integers, four 16-bit integers, or eight 8-bit integers may be processed concurrently."

Nowadays it is obsolete because of the SSEx technology. Sorry, but there is no instruction like PADDQ (take a look PADDx) in the specification.

The Shift-Instruction only accept 8Bit displacement or an other MMX Register to hold the amount of shifts. This means you cannot use a register like eax to do the job. Nice try but sometimes wishes have nothing to do with the real world.

By the way, please take a close look to your posted macro. Anyway, i think it seems not to be correct. Please think about the order of operation you want to do and the result you expect.

Because you use a macro which will emit code at any time you use it you can try (untested):

TEST macro a, rot
; Result := (A shl (64-rot)) xor (A shr rot);
  MOVQ    mm6, a
  PSLLQ   a, 64-rot
  PSRLQ   mm6, rot
  PXOR    a, mm6
endm

这篇关于MMX-使用恒定字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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