问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/13042482/mmx-working-with-constant-bytes