Recent

Author Topic: Asm problem - pushfd command is not recognized  (Read 680 times)

Conrad_404

  • New member
  • *
  • Posts: 9
Asm problem - pushfd command is not recognized
« on: August 01, 2025, 09:42:08 pm »
Hi,

I'm currently trying to port an old procedure written in TMT Pascal to a program written in Lazarus 4.2. The procedure is supposed to recognize the presence of a CPUID.
Unfortunately, during compilation, I get a message that the pushfd and popfd commands are not recognized (see the attachement). Has anyone encountered this situation?
Here is the code:

{$ASMMODE INTEL}
function CPUID_PRESENT : boolean; assembler;
asm
  pushfd                 // save flags
      pop  EAX
     mov  EBX, EAX
      xor  EAX, $00200000 // switch $00200000 cell
    push  EAX
  popfd                 // save changed flags
pushfd
    pop  EAX
    cmp  EAX, EBX
       jz  @NO_CPUID      // are the flags still changed? if not - there's no cpuid
   mov  AL, 1
@NO_CPUID:
end;

gues1

  • Guest
Re: Asm problem - pushfd command is not recognized
« Reply #1 on: August 01, 2025, 10:10:12 pm »
May be the rigth instructions are PUSHFQ / POPFQ if you are using 64 bit and PUSHF / POPF for 32 bit.
« Last Edit: August 01, 2025, 10:20:15 pm by gues1 »

Khrys

  • Sr. Member
  • ****
  • Posts: 342
Re: Asm problem - pushfd command is not recognized
« Reply #2 on: August 04, 2025, 07:28:23 am »
Looking at the FPC source tree, the lists of recognized Intel-style mnemonics for  x86  (32-bit)  and AMD64  (64-bit)  are located at  compiler/i386/i386int.inc  and  compiler/x86_64/x8664int.inc,  respectively.

The 32-bit version defines  pushf, pushfw  and  pushfd,  while the 64-bit version defines  pushf, pushfw, pushfq  but not  pushfd.
So if you need to support both variants you'll have to use an  ifdef  guard, e.g.  {$ifdef CPU64} pushfq {$else} pushfd {$endif}.

 

TinyPortal © 2005-2018