Recent

Author Topic: FPC 3.2.2 Assembly Problem when using -a and -A Options  (Read 574 times)

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
FPC 3.2.2 Assembly Problem when using -a and -A Options
« on: May 10, 2025, 09:35:19 am »
Hi,
I have a strange Problem on compile a Source Code:
when I doing the following Command:

Code: Bash  [Select][+][-]
  1. fpc -dDLLEXPORT -dLANGDEU -n -B -O3 -Os -CD -a -al -Anasmwin64 xmm.pas

I get message:

Code: Bash  [Select][+][-]
  1. xmm.pas:148: error: mismatch in operand sizes
  2. xmm.pas(144,1) Error: Error while assembling exitcode 1
  3. xmm.pas(144,1) Fatal: There were 2 errors compiling module, stopping
  4. Fatal: Compilation aborted
  5. Error: C:\fpcupdeluxe\fpc\bin\x86_64-win64\ppcx64.exe returned an error exitcode

when I compile with:

Code: Bash  [Select][+][-]
  1. fpc -dDLLEXPORT -dLANGDEU -n -B -O3 -Os -CD -a -al -Anasmwin64 -Xe -sh xmm.pas

I get message:

Code: Bash  [Select][+][-]
  1. xmm.pas(12,1) Error: Duplicate identifier "SYSTEM"
  2. xmm.pas(12,1) Error: Compilation raised exception internally
  3. Fatal: Compilation aborted
  4. An unhandled exception occurred at $00000001000615EC:
  5. EAccessViolation: Access violation
  6.   $00000001000615EC
  7.   $0000000100045FFA
  8.   $00000001000461DB
  9.   $000000010019D378
  10.   $000000010003DCE5
  11.   $0000000100017941
  12.   $0000000100001A3D
  13.   $0000000100001A56
  14.   $0000000100014280
  15.   $0000000100001850
  16.   $00007FF815EF257D
  17.   $00007FF8163EAF08
  18.  
  19. Error: C:\fpcupdeluxe\fpc\bin\x86_64-win64\ppcx64.exe returned an error exitcode

Before Line 12 (11): {$mode ObjFPC}{$H+}
          Line       12 : is empty
After   Line 12 (13): interface

When I compile without -a and -A Options, FPC does not stuck into troubles, and produce a executable.
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: FPC 3.2.2 Assembly Problem when using -a and -A Options
« Reply #1 on: May 10, 2025, 04:22:54 pm »
okay. I found a solution by my self:
I had the following Code:

Code: ASM  [Select][+][-]
  1. lock xchg [target], eax
  2.  
  3. // instead of:
  4. xchg dword ptr [target], eax

The "lock" is not needed by modern CPU's, because they do this self.
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

Khrys

  • Sr. Member
  • ****
  • Posts: 459
Re: FPC 3.2.2 Assembly Problem when using -a and -A Options
« Reply #2 on: May 12, 2025, 07:36:44 am »
The "lock" is not needed by modern CPU's, because they do this self.

True, but only for the  xchg  instruction:

Quote
If a memory operand is referenced, the processor’s locking protocol is automatically implemented for the duration of the exchange operation, regardless of the presence or absence of the LOCK prefix or of the value of the IOPL.

Note that the change you made (adding a size specifier) can still be combined with the  lock  prefix; the following compiles/assembles just fine:

Code: ASM  [Select][+][-]
  1. lock xchg dword ptr [target], eax

 

TinyPortal © 2005-2018