Recent

Author Topic: "Selected assembler _reader_ (not mode) not supported" message  (Read 3184 times)

440bx

  • Hero Member
  • *****
  • Posts: 3946
"Selected assembler _reader_ (not mode) not supported" message
« on: February 23, 2019, 02:48:42 pm »
Hello,

I have the following assembly statement
Code: Pascal  [Select][+][-]
  1. var
  2.   Selector_DS   : word;
  3.  
  4. begin
  5.   asm
  6.     mov  [Selector_DS], ds
  7.   end;
  8.  
  9.   etc...
  10.  
which FPC compiles without complaint for a 64bit target but gives the error mentioned in the title when switching to a 32bit target.  The error line number reported (and highlighted by Lazarus) is for the "asm" line.

In both build modes (32 and 64 bit) the assembler syntax is set to "Intel".  The compiler v3.0.4 is in mode OBJFPC.

The question is: what do I have to do for FPC to accept that assembly statement for a 32bit target ?

Thank you for your help.

PS: Delphi 2 accepts that statement without complaint.
« Last Edit: February 23, 2019, 03:48:12 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: "Selected assembler mode not supported" message
« Reply #1 on: February 23, 2019, 03:00:34 pm »
Are you sure the error message is not that the selected *addressing* mode is not supported?

You cannot write to absolute addresses on most x86-64 platforms. Try using [rip + Selector_DS] instead.

Delphi 2 does not support x86-64.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: "Selected assembler mode not supported" message
« Reply #2 on: February 23, 2019, 03:47:35 pm »
Hello Jonas,

Are you sure the error message is not that the selected *addressing* mode is not supported?

You cannot write to absolute addresses on most x86-64 platforms. Try using [rip + Selector_DS] instead.

Delphi 2 does not support x86-64.
No, the message does not refer to addressing mode.  It refers to "assembler reader" (not mode as I incorrectly stated in the title). 

Here is a bare bones example that reproduces the problem (code is in the attachment too):
Code: Pascal  [Select][+][-]
  1. {$APPTYPE CONSOLE}
  2.  
  3. program ConsoleAsmSelectorEntry;
  4.  
  5. uses
  6.   sysutils
  7.   ;
  8.  
  9. procedure DoIt;
  10. var
  11.   Selector_DS : word;
  12.  
  13. begin
  14.   { we only get here when compiling for a 32bit target                        }
  15.  
  16.   asm                               // it doesn't like this line
  17.     mov [Selector_DS], ds
  18.   end;
  19.  
  20.   writeln('selector is : ', IntToHex(Selector_DS, 0));
  21.  
  22. end;
  23.  
  24. begin
  25.   DoIt;
  26.  
  27.   writeln('Press <return>/<enter> to end this program');
  28.   readln;
  29. end.
  30.  
  31. { compiler error messages for target Win32 are:                               }
  32.  
  33. {
  34.   Compile Project, Mode: Win32, Target: lib\i386-win32\ConsoleAsmSelectorEntry.exe: Exit code 1, Errors: 1
  35.   ConsoleAsmSelectorEntry.lpr(16,3) Fatal: Selected assembler reader not supported
  36. }
  37.  
The program compiles fine with FPC for a 64bit target, won't compile for a 32bit target.  Delphi 2 compiles it just fine (of course, 32bit target only since that's the only thing it can do.)

I attached the above code along with the Lazarus project files to provide the compile settings I am using.

The error message is:
Quote
Fatal: Selected assembler reader not supported
and I don't see why the compiler is emitting that error.

Thank you for looking at the problem.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: "Selected assembler _reader_ (not mode) not supported" message
« Reply #3 on: February 23, 2019, 04:31:37 pm »
Somehow FPC (or it is Lazarus problem?) resets the assembler mode to default one, even if using the -RIntel option. Maybe it is handling of the -MObjFPC option, which resets its to default one?

Quote
/mnt/shares/ohjelmointi2/fpc/i386/trunk/3.3.1/binary/trunk/bin/i386-linux/fpc
-Rintel
-MObjFPC
-Scghi
-gw2
-godwarfsets
-gl
-l
-vewnhibq
-Fi/home/john/tmp/lib/i386-linux
-Fu.
-FU/home/john/tmp/lib/i386-linux/
-FE/home/john/tmp/
-o/home/john/tmp/project1

For time being, you need to add {$asmmode intel} compiler directive at top of your source code.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: "Selected assembler _reader_ (not mode) not supported" message
« Reply #4 on: February 23, 2019, 04:42:34 pm »
Somehow FPC (or it is Lazarus problem?) resets the assembler mode to default one, even if using the -RIntel option. Maybe it is handling of the -MObjFPC option, which resets its to default one?

Quote
/mnt/shares/ohjelmointi2/fpc/i386/trunk/3.3.1/binary/trunk/bin/i386-linux/fpc
-Rintel
-MObjFPC
-Scghi
-gw2
-godwarfsets
-gl
-l
-vewnhibq
-Fi/home/john/tmp/lib/i386-linux
-Fu.
-FU/home/john/tmp/lib/i386-linux/
-FE/home/john/tmp/
-o/home/john/tmp/project1

For time being, you need to add {$asmmode intel} compiler directive at top of your source code.
Cyrax, thank you.  Simple fix, works great.  I seriously doubt I would have figured it out, I just kept looking, comparing and re-verifying all the settings and left wondering why it wasn't working.

Thanks again.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: "Selected assembler _reader_ (not mode) not supported" message
« Reply #5 on: February 23, 2019, 05:04:05 pm »
I indeed misread the original message, I thought the error appeared on x86-64 and not on i386 instead of the other way around.

It's indeed a compiler bug. I've just fixed it on trunk.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: "Selected assembler _reader_ (not mode) not supported" message
« Reply #6 on: February 23, 2019, 05:09:49 pm »
It's indeed a compiler bug. I've just fixed it on trunk.
That's good news.   Will the fix be part of the next release (v3.2 I believe) ?
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: "Selected assembler _reader_ (not mode) not supported" message
« Reply #7 on: February 23, 2019, 05:10:17 pm »
It's indeed a compiler bug. I've just fixed it on trunk.
That's good news.   Will the fix be part of the next release (v3.2 I believe) ?
Probably, yes.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: "Selected assembler _reader_ (not mode) not supported" message
« Reply #8 on: February 23, 2019, 05:19:49 pm »
It's indeed a compiler bug. I've just fixed it on trunk.
That's good news.   Will the fix be part of the next release (v3.2 I believe) ?
Probably, yes.
Excellent.  I'm looking forward to v3.2.  Thank you.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018