Recent

Author Topic: Lazarus IDE inconsistency  (Read 9722 times)

abtaylr

  • Full Member
  • ***
  • Posts: 107
Lazarus IDE inconsistency
« on: July 01, 2016, 07:09:39 pm »
In reading the Lazarus/FreePascal manuals early on, I had discovered that Lazarus can use either AT&T or Intel ASM code blocks. No where that I looked explained how. The limited available information is found in: Programmer’s Guide for Free Pascal, Version 3.0.0 Document version 3.0 November 2015 by Michaël Van Canneyt.

Logic left me believing that compiler switches or flags must exist, but the documentation did not set it out, see: User’s Guide for Free Pascal, Version 3.0.0 Document version 3.0 November 2015 Michaël Van Canneyt & Florian Klämpfl, Appendix A:  Alphabetical listing of command line options. I have had a memory that I have seen somewhere a reference to those switches. Perhaps it was on a forum comment.

The other day I finally discovered, at least, one such source in the fpc.cfg file which in its default form shows: 
Code: Pascal  [Select][+][-]
  1. # Assembler reader mode
  2. #      -Rdefault  use default assembler
  3. #      -Ratt      read AT&T style assembler
  4. #      -Rintel    read Intel style assembler
  5. #
  6. # All assembler blocks are AT&T styled by default
  7. #-Ratt

So, in Lazarus setting options for a project I am working on I tried to select '-Rintel' in Project->Project Options->Compiler Options->All Options and found that the only option showing is '-Rdefault'.  Now I am sure that I could probably enter it directly, but I hate seeing other people having to go through the search that I have done and then ended up converting Intel code over to At&T just to get it to work.

Recently, on the Forum a member pointed me to a define -- {$asmmode intel}. That was helpful, but for such a simple matter I think it should be placed in the compiler switches listing for all options referred to above.


Handoko

  • Hero Member
  • *****
  • Posts: 5159
  • My goal: build my own game engine using Lazarus
Re: Lazarus IDE inconsistency
« Reply #1 on: July 01, 2016, 08:12:05 pm »
Hello. I don't really understand what are their differences and when to use it. But I know we can change the assembler style easily:

Lazarus main menu > Project > Project Options > Compiler Options > Parsing > Assembler style (-R)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9913
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus IDE inconsistency
« Reply #2 on: July 01, 2016, 08:22:27 pm »
The compileroptions are documented http://www.freepascal.org/docs-html/user/usersu16.html

The list in the screenshot is retrieved from the help output of the fpc.exe itself. If it does not include certain options, no idea why not.

abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Lazarus IDE inconsistency
« Reply #3 on: July 01, 2016, 08:37:54 pm »
The flag -R needs to have something added after it, as I learned after much effort those options are:  -Rintel, -Rat&t and -Rdefault.  The last one defaults to -Rat&t.

An intel asm block looks like this:

Code: Pascal  [Select][+][-]
  1.     asm
  2.   sub    rsp,28h      ; shadow space, aligns stack
  3.   mov    rcx, 0       ; hWnd = HWND_DESKTOP
  4.   lea    rdx, message ; LPCSTR lpText
  5.   lea    r8,  caption ; LPCSTR lpCaption
  6.   mov    r9d, 0       ; uType = MB_OK
  7.   call   MessageBoxA  ; call MessageBox API function
  8.   mov    ecx, eax     ; uExitCode = MessageBox(...)
  9.     end;

While an AT&T asm block looks like this:

Code: Pascal  [Select][+][-]
  1.         .file   "hello.c"
  2.         .def    ___main;        .scl    2;      .type   32;     .endef
  3.         .text
  4. LC0:
  5.         .ascii "Hello, world!\12\0"
  6. .globl _main
  7.         .def    _main;  .scl    2;      .type   32;     .endef
  8. _main:
  9.         pushl   %ebp
  10.         movl    %esp, %ebp
  11.         subl    $8, %esp
  12.         andl    $-16, %esp
  13.         movl    $0, %eax
  14.         movl    %eax, -4(%ebp)
  15.         movl    -4(%ebp), %eax
  16.         call    __alloca
  17.         call    ___main
  18.         movl    $LC0, (%esp)
  19.         call    _printf
  20.         movl    $0, %eax
  21.         leave
  22.         ret
  23.         .def    _printf;        .scl    2;      .type   32;     .endef

It's not all that difficult to convert the code from one to the other, but it is time wasted when we could have had in the 'All Option' checkbox list in Project Options->Compiler Options->All Options check boxes for the two options of -Rat&t and -Rintel.  Of course now that I have finally found the answer, I will never have the problem, but I am concerned that others are going to have it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9913
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus IDE inconsistency
« Reply #4 on: July 01, 2016, 09:10:02 pm »
Well for me it lists default, att and intel when I press the "all" button.

What fpc version do you have, and on which platform?

As I said the IDE just asks the compiler to list all options. No idea why your fpc does not list them. Maybe newer does, maybe it only does on certain platform....

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Lazarus IDE inconsistency
« Reply #5 on: July 01, 2016, 09:27:22 pm »
Well for me it lists default, att and intel when I press the "all" button.

I guess you have FPC trunk. I just tested "fpc -h" with my FPC 3.0 and indeed it only lists "-Rdefault".
If somebody finds which revision fixed it, please ask FPC developers to merge it to fixes branch.

The All Options window is parsed from "fpc -h" and "fpc -i" outputs, thus it works with different versions and configurations automatically.
The "Assembler style (-R)" setting in Parsing options page should be easy to find, at least if you use the filter in options dialog.
« Last Edit: July 01, 2016, 09:37:28 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9913
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus IDE inconsistency
« Reply #6 on: July 01, 2016, 09:44:46 pm »
fpc 3.0.0 (however build myself from svn) on win32

fpc -h
Code: [Select]
Free Pascal Compiler version 3.0.0 [2015/12/02] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
C:\FPC\rel_3_0_0\nogl\bin\i386-win32\fpc.exe [options] <inputfile> [options]
 Only options valid for the default or selected platform are listed.
....
  -R<x>  Assembler reading style:
      -Rdefault  Use default assembler for target
      -Ratt      Read AT&T style assembler
      -Rintel    Read Intel style assembler

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: Lazarus IDE inconsistency
« Reply #7 on: July 01, 2016, 10:23:02 pm »
If I put "freepascal intel assembler" into google, I get the $asmmode directive + explanation as first hit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Lazarus IDE inconsistency
« Reply #8 on: July 02, 2016, 12:10:55 am »
fpc 3.0.0 (however build myself from svn) on win32
...

Same goes for standard fpc 3.0.0 release (win32).

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Lazarus IDE inconsistency
« Reply #9 on: July 02, 2016, 01:04:38 am »
Strange. My compiler is 64-bit from Manjaro repository :

Code: [Select]
$ fpc -h
Free Pascal Compiler version 3.0.0 [2015/11/26] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
/usr/bin/fpc [options] <inputfile> [options]
 Only options valid for the default or selected platform are listed.
...
      -P<x>      Set target CPU (arm,avr,i386,jvm,m68k,mips,mipsel,powerpc,powerpc64,sparc,x86_64)
  -R<x>  Assembler reading style:
      -Rdefault  Use default assembler for target
  -S<x>  Syntax options:
      -S2        Same as -Mobjfpc
...

Is assembler selection only for 32-bit syntax?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Lazarus IDE inconsistency
« Reply #10 on: July 02, 2016, 01:29:39 am »
My cross-compiler  (win32->win64: ppcrossx64.exe) also only lists the -Rdefault option.

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus IDE inconsistency
« Reply #11 on: July 02, 2016, 07:16:39 pm »
Strange. My compiler is 64-bit from Manjaro repository :
...
Is assembler selection only for 32-bit syntax?
My cross-compiler  (win32->win64: ppcrossx64.exe) also only lists the -Rdefault option.
Same here in trunk. fpc -Pi386 (I have i386 cross compiler) lists all 3 options, though. However, the -Rintel and {$asmmode intel} works for both i386 and x86_64, I guess it's a bug in the compiler help output.

abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Lazarus IDE inconsistency
« Reply #12 on: July 03, 2016, 06:42:13 am »
Sorry, I should have put that in to begin with.  I am using Kubuntu 16.04 LTS 64Bit.  As for FPC and Lazarus, I am using:

svn checkout http://svn.freepascal.org/svn/fpc/tags/release_3_0_0 fpc fpc-3.0.0

svn co http://svn.freepascal.org/svn/lazarus/tags/lazarus_1_6 lazarus-1.6.0

abtaylr

  • Full Member
  • ***
  • Posts: 107
Re: Lazarus IDE inconsistency
« Reply #13 on: July 03, 2016, 11:19:30 am »
I just did my weekly update, only this time I used the fixes branch for fpc and lazarus.  Fpc is still only showing the -Rdefault and Lazarus only shows the same as in the graphic I attached.  I am using Kubuntu 16.04 LTS 64bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus IDE inconsistency
« Reply #14 on: July 03, 2016, 11:51:30 am »
I just did my weekly update, only this time I used the fixes branch for fpc and lazarus.  Fpc is still only showing the -Rdefault and Lazarus only shows the same as in the graphic I attached.  I am using Kubuntu 16.04 LTS 64bit.
Well, it won't be magically fixed just because you post it in the forum. Report to the bugtracker.

 

TinyPortal © 2005-2018