how to detect which ASM mode the compiler is in? lazarus / 62-General ---------------------------------------------------------------------- jamie · 2023-11-17 23:48 I ran into a strange issue where I decided to do an online assembler... ASm <<<< Unsupported assembler parser.  ... END:  Compiler stopped at the ASM, stating there was an unsupported assembler parser.?  Setting the compiler in the project to Default, Intel or ATT made no difference, however, setting it in source prior to the attempted assembler did. {$ASMMODE ATT} ...all is fine /// How can I determine the current ASM mode at the point where the compiler chokes?  I did this in a patch of code in an existing project instead of starting a new one. Also this is FPC 3.0.4 but I am not sure if that really makes a difference here. ---------------------------------------------------------------------- ASerge · 2023-11-18 08:02 Quote from: jamie on November 18, 2023, 12:48:46 amI ran into a strange issue where I decided to do an online assembler... ASm <<<< Unsupported assembler parser.  ... END:  Compiler stopped at the ASM, stating there was an unsupported assembler parser.? As far as I know the asm operator is enabled in all modes. ---------------------------------------------------------------------- Avinash · 2023-11-18 09:01 not working... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  {$ASMMODE INTEL}  asm    mov ebx,eax  end;   {$PUSH}  {$ASMMODE ATT}  asm    movl %eax,%ebx  end;  {$POP}   asm    mov ebx,eax  end;end. ---------------------------------------------------------------------- jamie · 2023-11-18 15:47 The only other thing I left out is that this is done with the 32-bit compiler. it's strange this happens, I have not found the reason for it, yet. ---------------------------------------------------------------------- ASerge · 2023-11-18 18:16 Quote from: Avinash on November 18, 2023, 10:01:53 amnot working... As documented in $ASMMODE : Assembler mode (Intel 80x86 only) These switches are local, and retain their value to the end of the unit that is compiled, unless they are replaced by another directive of the same type ---------------------------------------------------------------------- Avinash · 2023-11-18 18:47 Quote from: ASerge on November 18, 2023, 07:16:07 pmThese switches are local, and retain their value to the end of the unit that is compiled, unless they are replaced by another directive of the same type The same is said for local directives in general: The local directives influence the compiler’s behavior from the moment they’re encountered until the moment another switch annihilates their behavior, or the end of the current unit or program is reached. And at the same time: 1.2.63 $PUSH : Save compiler settings The $PUSH directive saves the current values of all local compiler directives 1.2.62 $POP : Restore compiler settings The $POP directive restores the values of all local compiler directives with the last values that were stored And, among other things, it would be convenient in a case like Jamie's. ---------------------------------------------------------------------- ASerge · 2023-11-18 19:30 Quote from: Avinash on November 18, 2023, 07:47:11 pmAnd, among other things, it would be convenient in a case like Jamie's. For everything but that. None of the local directives say about the actions as for $ASMMODE. Perhaps in $PUSH and $POP it was also possible to specify that with the exception of $ASMMODE. ---------------------------------------------------------------------- Avinash · 2023-11-18 19:57 Quote from: ASerge on November 18, 2023, 08:30:41 pmFor everything but that. None of the local directives say about the actions as for $ASMMODE. Perhaps in $PUSH and $POP it was also possible to specify that with the exception of $ASMMODE. ...and with the exception of $CALLING? The list is not complete... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function WrFirst: Integer;begin  Write('FIRST ');end; function WrSecond: Integer;begin  Write('SECOND ');end; {$CALLING PASCAL}procedure TestPascal1(X,Y: Integer);beginend; {$PUSH}{$CALLING STDCALL}{$POP} procedure TestPascal2(X,Y: Integer);beginend; begin  TestPascal1(WrFirst, WrSecond);  WriteLn;  TestPascal2(WrFirst, WrSecond);end. Output: QuoteFIRST SECOND SECOND FIRST ---------------------------------------------------------------------- jamie · 2023-11-18 20:16 Not sure where my problem is, I still use older lazarus because it uses 3.0.4 which compiles a DLL I have correctly, anything newer I have problems with the DLL.   But in anycase, the problem of the same versions in the 64 bit IDE and compiler does not have this issue which I use most of the time.  Getting back to the 32 bit one.  if i use {$Mode DElphi} then it works. but using ObjFpc it does not work.  However, If I put into custom options the -RAtt for example or just -RDefault. it works. But that is only doable per project.  In the parser menu it makes no difference what I select, it has no parser for ASM while in objFpc mode unless I do an inline switch or use the custom options per project.  Strange I've never seen this before, maybe because it works correctly in the 64 bit target. As for the trunk, I always test with the 64 bit install so I don't know if there is some issue there. This is on windows. In case you would like to see the message QuoteCompile Project, Target: C:\Users\xxxxxx\AppData\Local\Temp\project1.exe: Exit code 1, Errors: 1 unit1.pas(34,3) Fatal: Selected assembler reader not supported ---------------------------------------------------------------------- Avinash · 2023-11-18 20:41 Full recompilation -B doesn't help? ---------------------------------------------------------------------- jamie · 2023-11-18 21:06 No, I've already done that, I looked around and it seems to be a known issue dating back to 2013 or so, exactly what I have found and it only seems to effect the 32 bit target version.  That's fine, I'll live with it. Just never noticed it before. ---------------------------------------------------------------------- ASerge · 2023-11-19 07:15 Quote from: Avinash on November 18, 2023, 08:57:12 pm...and with the exception of $CALLING? The list is not complete... Output: QuoteFIRST SECOND SECOND FIRSTAn unfortunate example. The order in which functions are called does not correlate with the order in which parameters are passed. And generally undefined. On my Win64, the program outputs QuoteSECOND FIRST SECOND FIRST ---------------------------------------------------------------------- Avinash · 2023-11-19 08:40 Quote from: ASerge on November 19, 2023, 08:15:02 amThe order in which functions are called does not correlate with the order in which parameters are passed. And generally undefined.If only this could be demonstrated by just one example... Quote from: ASerge on November 19, 2023, 08:15:02 amWin64 https://wiki.freepascal.org/Win64/AMD64_API#Calling_convention Calling conventions in Win64 for AMD There is only one calling convention. Actually Microsoft include files are shared among Windows 32 bit and 64 bit. Functions modifiers like stdcall, cdecl and fastcall are ignored on 64bit windows since they use an unique calling convention. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TestPascal1(X,Y: Integer); pascal;begin  WriteLn;  WriteLn('TestPascal1:');  WriteLn('Ofs(X) = ',Ofs(X));  WriteLn('Ofs(Y) = ',Ofs(Y));end; procedure TestStd(X,Y: Integer); stdcall;begin  WriteLn;  WriteLn('TestStd:');  WriteLn('Ofs(X) = ',Ofs(X));  WriteLn('Ofs(Y) = ',Ofs(Y));end; {$CALLING PASCAL}{$PUSH}{$CALLING STDCALL}{$POP} procedure TestPascal2(X,Y: Integer);begin  WriteLn;  WriteLn('TestPascal2:');  WriteLn('Ofs(X) = ',Ofs(X));  WriteLn('Ofs(Y) = ',Ofs(Y));end; begin  TestPascal1(0,0);  TestStd(0,0);  TestPascal2(0,0);end. ---------------------------------------------------------------------- PascalDragon · 2023-11-19 17:02 Quote from: Avinash on November 18, 2023, 07:47:11 pmAnd at the same time: 1.2.63 $PUSH : Save compiler settings The $PUSH directive saves the current values of all local compiler directives 1.2.62 $POP : Restore compiler settings The $POP directive restores the values of all local compiler directives with the last values that were stored That's a bug in the documentation, $Push and $Pop only work on all local switches, not directives. Plus some local directives like $Warn or $Align that all have been explicitely enabled for $Push/$Pop. ---------------------------------------------------------------------- AlexTP · 2023-11-19 19:13 Reported to https://gitlab.com/freepascal.org/fpc/documentation/-/issues/39363