-2

My project in Delphi 10.1 has some assembly functions like this:

  function MyFunc: Word;
  asm
    PUSH   0
    FNSTCW [ESP].Word
    POP    EAX
  end;

I need compile project in win64, but some lines like POP EAX has E2116 Invalid combination of opcode and operands Error.

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • 1
    Use function Get8087CW from System unit, it should work fine for both platforms (Win32/Win64). – Andrei Galatyn Oct 04 '16 at 08:53
  • x86_64 doesn't support 32-bit push/pop – phuclv Oct 04 '16 at 08:56
  • Note that x86 and x64 use differently named registers in their calling convention, and often different opcodes. Strongly consider @AndreiGalatyn's advice, because you will have to (at least) duplicate all the functions. – Caleth Oct 04 '16 at 08:57
  • What is your question? Efforts to solve? – Free Consulting Oct 04 '16 at 09:45
  • 5
    Why does your 64 bit code want to know the 8087 control word? It doesn't use the 8087 unit for floating point math. It uses the SSE unit. You have got ahead of yourself. Step 1 is to understand comprehensively why your code exists and what purpose it serves. Don't just translate it literally. – David Heffernan Oct 04 '16 at 10:36

1 Answers1

3

Rather than translating the assembly to x64, you should use the Get8087CW() function in the System unit instead. It should work fine for both platforms (Win32/Win64):

function MyFunc: Word;
begin
  Result := Get8087CW;
end;

In order to translate any other assembly code (which you didn't provide here) from x86 to x64, I suggest you to learn x64 assembling programming.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Andrei Galatyn
  • 3,322
  • 2
  • 24
  • 38
  • 3
    This is true, but perhaps misses the point. The x64 code doesn't use 8087 unit. It uses SSE unit. – David Heffernan Oct 04 '16 at 10:35
  • @David: I guess the piece of the code in the question is just example and for this example he don't need to use asm. If he start to rewrite the code to x64, the function will not be in use anyway. But you right, accessing FPU control register is quite useless in x64 mode. – Andrei Galatyn Oct 04 '16 at 11:07
  • 2
    OK, but then once he has removed the code that reads the 8087 CW, there's nothing at all left in the question. Question isn't really useful in its current form. – David Heffernan Oct 04 '16 at 11:08
  • Thanks all; this project make a delphi package and for capture videos with directshow. It has written by Delphi 7 and use DSPack component. Now, customer need 64bit version of package under delphi 10.1. its developer not available and I do not know. Thus I made a mistake about this question. I need 64bit of DSPack or any alternative, actually. I think must to create another question. I'm sorry and thank's for your replies. – Asghar Nemati Oct 16 '16 at 13:47