3

I have this snippet of code:

@combinerows:
    mov esi,eax
    and edi,Row1Mask
    and ebx,Row2Mask
    or ebx,edi
    //NewQ:= (Row1 and Row1Mask) or (Row2 and Row2Mask);

  //Result:= NewQ xor q;
  PUNPCKDQ mm4,mm5   <-- I get an error here
  //mov eax,[eax].q
  movd eax,mm4

  //q:= NewQ;
  mov [esi].q,ebx
  xor eax,ebx  //Return difference.

I get this error:

[Pascal Error] SDIMAIN.pas(718): E2003 Undeclared identifier: 'PUNPCKDQ'

Am I doing something wrong, or does Delphi 2007 not support a full set of MMX/SSE instructions?

Johan
  • 74,508
  • 24
  • 191
  • 319
  • 4
    For any mnemonics that Delphi doesn't recognize, you can use the `DB` command to insert the raw instruction bytes. – Rob Kennedy Jun 20 '11 at 21:44
  • I didn't know delphi supported any such instructions. When was support added? – David Heffernan Jun 20 '11 at 21:51
  • @David: I'm sure they were in D7 already. – Giel Jun 20 '11 at 22:29
  • 1
    Anyway just in case people were wondering: replacing `push ebx` with `movd mm0,ebx` is slower, and a `movq mm4,[eax]` to load 2 integers in one go is slower than loading the two integers using `mov ebx,[eax] + mov ecx,[eax+4]` Using the mmx registers as dummy stack does free up `esp` for nifty stuff though. That **did** work. – Johan Jun 20 '11 at 22:31

2 Answers2

4

A quick Google gives information on a PUNPCKLDQ rather than PUNPCKDQ.

D2007 accepts PUNPCKLDQ
and even better it also supports PUNPCKHDQ, which lets you transfer a high order dword to a low dword enabling you to load it into a general purpose register.

Johan
  • 74,508
  • 24
  • 191
  • 319
Gerry Coll
  • 5,867
  • 1
  • 27
  • 36
  • Never mind my previous comment, this instructions put the two **low** order dwords and scrabbles them, I need to scramble the high order dwords, to get at that `hidden` high dword see :-). PUNPCKHDQ is the answer. – Johan Jun 20 '11 at 22:00
  • 1
    Johan, are you really saying that the answer to why Delphi doesn't support PUNPCKDQ is that anyone wishing to use it should really use PUNPCKHDQ or PUNPCKLDQ instead? They're three distinct instructions with different effects on their operands. I don't see how this answers the question you asked. – Rob Kennedy Jun 20 '11 at 22:17
  • @Rob, well it **did** answer the question, the code with `PUNPCKHDQ` worked beautifully. Maybe I looked up the wrong instruction, in which case I apologize. I do not mean to say that people should use PUNPCKHDQ/...L.. instead of whatever MMX instruction, just that it worked for me. – Johan Jun 20 '11 at 22:36
4

Delphi 2007 supports the MMX and SSE instruction sets. Certainly, Delphi 2010 and XE support up to the SSE4.2 instruction sets (but so far no support for AVX).

However, Delphi is correct to complain about your "PUNPCKDQ" instruction: If you search the Intel® 64 and IA-32 Architectures Software Developer’s Manual (especially Volumes 2A and 2B would be relevant), you will NOT find an instruction by that name. I.e., it is your mistake, not Delphi's lack of support for this instruction.

PhiS
  • 4,540
  • 25
  • 35
  • Yeah I'm starting to realize that now, I was reading a MMX guide to brush up on this stuff, but it's full of the wrong keywords. Very annoying. – Johan Jun 21 '11 at 15:56