Recent

Author Topic: Free Pascal and Intel Core 64-bit assembly language  (Read 21471 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #15 on: March 16, 2015, 05:30:05 am »
I don't think the textmode IDE can crosscompile cross- architecture. So then you would indeed have to build a full win64 build. Or use notepad and fpc

Rick314

  • New Member
  • *
  • Posts: 28
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #16 on: March 16, 2015, 06:49:19 am »
x86_64-linux, should be no different on x86_64-win64. If you use fpc command line, pass -Px86_64 -Twin64 (probably this one is not needed since the cross compiler already targets win64 by default) before the filename. In Lazarus, you have in the project options dialog.
Making progress but not there yet. First, where is documentation for the "-P" option to fpc?  I can't find it anywhere I looked (running fpc with no parameters, user's guide, programmers ref...). Second, with file asm64test1.pas containing the code you provided above after "Did you mean", I now get this:

C> fpc -Px86_64 asm64test1
Free Pascal Compiler version 2.6.4 [2014/03/06] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling asm64test1.pas
Linking asm64test1.exe
asm64test1.pas(18,1) Warning: Object file "asm64test1.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_hidividend".
asm64test1.pas(18,1) Warning: Object file "asm64test1.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_divisor".
asm64test1.pas(18,1) Warning: Object file "asm64test1.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_quotient".
18 lines compiled, 0.1 sec , 30208 bytes code, 1748 bytes data
3 warning(s) issued

C> asm64test1
Runtime error 216 at $0000000100001421
  $0000000100001421
  $00000001000072A5

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #17 on: March 16, 2015, 07:26:21 am »
First, where is documentation for the "-P" option to fpc?  I can't find it anywhere I looked (running fpc with no parameters, user's guide, programmers ref...).
I didn't look at the docs, but fpc -h tells me:
Quote
$ fpc -h
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.1.1 [2015/03/12] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
/mnt/LinuxShared/fpc/fpc [options] <inputfile> [options]
 Only options valid for the default or selected platform are listed.
 Put + after a boolean switch option to enable it, - to disable it.
  @<x>   Read compiler options from <x> in addition to the default fpc.cfg
  -a     The compiler does not delete the generated assembler file
      -al        List sourcecode lines in assembler file
      -an        List node info in assembler file (-dEXTDEBUG compiler)
      -ao        Add an extra option to external assembler call (ignored for internal)
      -ap        Use pipes instead of creating temporary assembler files
      -ar        List register allocation/release info in assembler file
      -at        List temp allocation/release info in assembler file
  -A<x>  Output format:
      -Adefault  Use default assembler
      -Aas       Assemble using GNU AS
      -Agas      Assemble using GNU GAS                                                                                                                                                         
      -Agas-darwin Assemble darwin Mach-O64 using GNU GAS                                                                                                                                       
      -Amasm     Win64 object file using ml64 (Microsoft)                                                                                                                                       
      -Apecoff   PE-COFF (Win64) using internal writer                                                                                                                                         
      -Aelf      ELF (Linux-64bit) using internal writer                                                                                                                                       
      -Ayasm     Assemble using Yasm (experimental)                                                                                                                                             
      -Anasm     Assemble  using Nasm (experimental)                                                                                                                                           
      -Anasmwin64 Assemble Win64 object file using Nasm (experimental)                                                                                                                         
      -Anasmelf  Assemble Linux-64bit object file using Nasm (experimental)                                                                                                                     
      -Anasmdarwin Assemble darwin macho64 object file using Nasm (experimental)                                                                                                               
  -b     Generate browser info                                                                                                                                                                 
      -bl        Generate local symbol info                                                                                                                                                     
  -B     Build all modules                                                                                                                                                                     
  -C<x>  Code generation options:                                                                                                                                                               
      -C3        Turn on ieee error checking for constants                                                                                                                                     
      -Ca<x>     Select ABI; see fpc -i or fpc -ia for possible values                                                                                                                         
      -Cb        Generate code for a big-endian variant of the target architecture                                                                                                             
      -Cc<x>     Set default calling convention to <x>                                                                                                                                         
      -CD        Create also dynamic library (not supported)                                                                                                                                   
      -Ce        Compilation with emulated floating point opcodes                                                                                                                               
      -Cf<x>     Select fpu instruction set to use; see fpc -i or fpc -if for possible values                                                                                                   
      -CF<x>     Minimal floating point constant precision (default, 32, 64)                                                                                                                   
      -Cg        Generate PIC code                                                                                                                                                             
      -Ch<n>     <n> bytes heap (between 1023 and 67107840)                                                                                                                                     
      -Ci        IO-checking                                                                                                                                                                   
      -Cn        Omit linking stage                                                                                                                                                             
      -Co        Check overflow of integer operations                                                                                                                                           
      -CO        Check for possible overflow of integer operations                                                                                                                             
      -Cp<x>     Select instruction set; see fpc -i or fpc -ic for possible values
      -CP<x>=<y>  packing settings
         -CPPACKSET=<y>  <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 and 8
         -CPPACKENUM=<y>  <y> enum packing: 0, 1, 2 and 4 or DEFAULT or NORMAL
         -CPPACKRECORD=<y>  <y> record packing: 0 or DEFAULT or NORMAL, 1, 2, 4, 8, 16 and 32
      -Cr        Range checking
      -CR        Verify object method call validity
      -Cs<n>     Set stack checking size to <n>
      -Ct        Stack checking (for testing only, see manual)
      -CT<x>     Target-specific code generation options
         -CTcld                      Emit a CLD instruction before using the x86 string instructions
      -CX        Create also smartlinked library
  -d<x>  Defines the symbol <x>
  -D     Generate a DEF file
      -Dd<x>     Set description to <x>
      -Dv<x>     Set DLL version to <x>
  -e<x>  Set path to executable
  -E     Same as -Cn
  -fPIC  Same as -Cg
  -F<x>  Set file names and paths:
      -Fa<x>[,y] (for a program) load units <x> and [y] before uses is parsed
      -Fc<x>     Set input codepage to <x>
      -FC<x>     Set RC compiler binary name to <x>
      -Fd        Disable the compiler's internal directory cache
      -FD<x>     Set the directory where to search for compiler utilities
      -Fe<x>     Redirect error output to <x>
      -Ff<x>     Add <x> to framework path (Darwin only)
      -FE<x>     Set exe/unit output path to <x>
      -Fi<x>     Add <x> to include path
      -Fl<x>     Add <x> to library path
      -FL<x>     Use <x> as dynamic linker
      -Fm<x>     Load unicode conversion table from <x>.txt in the compiler dir
      -FM<x>     Set the directory where to search for unicode binary files
      -Fo<x>     Add <x> to object path
      -Fr<x>     Load error message file <x>
      -FR<x>     Set resource (.res) linker to <x>
      -Fu<x>     Add <x> to unit path
      -FU<x>     Set unit output path to <x>, overrides -FE
      -FW<x>     Store generated whole-program optimization feedback in <x>
      -Fw<x>     Load previously stored whole-program optimization feedback from <x>
  -g     Generate debug information (default format for target)
      -gc        Generate checks for pointers
      -gh        Use heaptrace unit (for memory leak/corruption debugging)
      -gl        Use line info unit (show more info with backtraces)
      -go<x>     Set debug information options
         -godwarfsets  Enable DWARF 'set' type debug information (breaks gdb < 6.5)
         -gostabsabsincludes  Store absolute/full include file paths in Stabs
         -godwarfmethodclassprefix  Prefix method names in DWARF with class name
      -gp        Preserve case in stabs symbol names
      -gs        Generate Stabs debug information
      -gt        Trash local variables (to detect uninitialized uses; multiple 't' changes the trashing value)
      -gv        Generates programs traceable with Valgrind
      -gw        Generate DWARFv2 debug information (same as -gw2)
      -gw2       Generate DWARFv2 debug information
      -gw3       Generate DWARFv3 debug information
      -gw4       Generate DWARFv4 debug information (experimental)
  -i     Information
      -iD        Return compiler date
      -iSO       Return compiler OS
      -iSP       Return compiler host processor
      -iTO       Return target OS
      -iTP       Return target processor
      -iV        Return short compiler version
      -iW        Return full compiler version
      -ia        Return list of supported ABI targets
      -ic        Return list of supported CPU instruction sets
      -if        Return list of supported FPU instruction sets
      -ii        Return list of supported inline assembler modes
      -io        Return list of supported optimizations
      -ir        Return list of recognized compiler and RTL features
      -it        Return list of supported targets
      -iu        Return list of supported microcontroller types
      -iw        Return list of supported whole program optimizations
  -I<x>  Add <x> to include path
  -k<x>  Pass <x> to the linker
  -l     Write logo
  -M<x>  Set language mode to <x>
      -Mfpc      Free Pascal dialect (default)
      -Mobjfpc   FPC mode with Object Pascal support
      -Mdelphi   Delphi 7 compatibility mode
      -Mtp       TP/BP 7.0 compatibility mode
      -Mmacpas   Macintosh Pascal dialects compatibility mode
  -n     Do not read the default config files
  -o<x>  Change the name of the executable produced to <x>
  -O<x>  Optimizations:
      -O-        Disable optimizations
      -O1        Level 1 optimizations (quick and debugger friendly)
      -O2        Level 2 optimizations (-O1 + quick optimizations)
      -O3        Level 3 optimizations (-O2 + slow optimizations)
      -O4        Level 4 optimizations (-O3 + optimizations which might have unexpected side effects)
      -Oa<x>=<y> Set alignment
      -Oo[NO]<x> Enable or disable optimizations; see fpc -i or fpc -io for possible values
      -Op<x>     Set target cpu for optimizing; see fpc -i or fpc -ic for possible values
      -OW<x>     Generate whole-program optimization feedback for optimization <x>; see fpc -i or fpc -iw for possible values
      -Ow<x>     Perform whole-program optimization <x>; see fpc -i or fpc -iw for possible values
      -Os        Optimize for size rather than speed
  -pg    Generate profile code for gprof (defines FPC_PROFILE)
  -P<x>  Target CPU / compiler related options:
      -PB        Show default compiler binary
      -PP        Show default target cpu
      -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
      -Sc        Support operators like C (*=,+=,/= and -=)
      -Sa        Turn on assertions
      -Sd        Same as -Mdelphi
      -Se<x>     Error options. <x> is a combination of the following:
         <n> : Compiler halts after the <n> errors (default is 1)
         w : Compiler also halts after warnings
         n : Compiler also halts after notes
         h : Compiler also halts after hints
      -Sf        Enable certain features in compiler and RTL; see fpc -i or fpc -ir for possible values)
      -Sg        Enable LABEL and GOTO (default in -Mtp and -Mdelphi)
      -Sh        Use reference counted strings (ansistring by default) instead of shortstrings
      -Si        Turn on inlining of procedures/functions declared as "inline"
      -Sk        Load fpcylix unit
      -SI<x>     Set interface style to <x>
         -SIcom     COM compatible interface (default)
         -SIcorba   CORBA compatible interface
      -Sm        Support macros like C (global)
      -So        Same as -Mtp
      -Ss        Constructor name must be init (destructor must be done)
      -Sv        Support vector processing (use CPU vector extensions if available)
      -Sx        Enable exception keywords (default in Delphi/ObjFPC modes)
      -Sy        @<pointer> returns a typed pointer, same as $T+
  -s     Do not call assembler and linker
      -sh        Generate script to link on host
      -st        Generate script to link on target
      -sr        Skip register allocation phase (use with -alr)
  -T<x>  Target operating system:
      -Tdarwin   Darwin/Mac OS X
      -Tfreebsd  FreeBSD
      -Tiphonesim  iPhoneSimulator
      -Tlinux    Linux
      -Tnetbsd   NetBSD
      -Topenbsd  OpenBSD
      -Tsolaris  Solaris
      -Twin64    Win64 (64 bit Windows systems)
  -u<x>  Undefines the symbol <x>
  -U     Unit options:
      -Un        Do not check where the unit name matches the file name
      -Ur        Generate release unit files (never automatically recompiled)
      -Us        Compile a system unit
  -v<x>  Be verbose. <x> is a combination of the following letters:
      e : Show errors (default)       0 : Show nothing (except errors)
      w : Show warnings               u : Show unit info
      n : Show notes                  t : Show tried/used files
      h : Show hints                  c : Show conditionals
      i : Show general info           d : Show debug info
      l : Show linenumbers            r : Rhide/GCC compatibility mode
      s : Show time stamps            q : Show message numbers
      a : Show everything             x : Show info about invoked tools
      b : Write file names messages   p : Write tree.log with parse tree
          with full path              v : Write fpcdebug.txt with
      z : Write output to stderr          lots of debugging info
      m<x>,<y> : Do not show messages numbered <x> and <y>
  -V<x>  Append '-<x>' to the used compiler binary name (e.g. for version)
  -W<x>  Target-specific options (targets)
      -WA        Specify native type application (Windows)
      -Wb        Create a bundle instead of a library (Darwin)
      -WB        Create a relocatable image (Windows)
      -WBxxxx    Set image base to xxxx (Windows)
      -WC        Specify console type application (Windows)
      -WD        Use DEFFILE to export functions of DLL or EXE (Windows)
      -We        Use external resources (Darwin)
      -WG        Specify graphic type application (Windows)
      -Wi        Use internal resources (Darwin)
      -WI        Turn on/off the usage of import sections (Windows)
      -WM<x>     Minimum Mac OS X deployment version: 10.4, 10.5.1, ... (Darwin)
      -WN        Do not generate relocation code, needed for debugging (Windows)
      -WP<x>     Minimum iOS deployment version: 8.0, 8.0.2, ... (iphonesim)
      -WR        Generate relocation code (Windows)
      -WX        Enable executable stack (Linux)
  -X     Executable options:
      -Xc        Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
      -Xd        Do not search default library path (sometimes required for cross-compiling when not using -XR)
      -Xe        Use external linker
      -Xf        Substitute pthread library name for linking (BSD)
      -Xg        Create debuginfo in a separate file and add a debuglink section to executable
      -XD        Try to link units dynamically      (defines FPC_LINK_DYNAMIC)
      -Xi        Use internal linker
      -XLA       Define library substitutions for linking
      -XLO       Define order of library linking
      -XLD       Exclude default order of standard libraries
      -Xm        Generate link map
      -XM<x>     Set the name of the 'main' program routine (default is 'main')
      -Xn        Use target system native linker instead of GNU ld (Solaris, AIX)
      -Xp<x>     First search for the compiler binary in the directory <x>
      -XP<x>     Prepend the binutils names with the prefix <x>
      -Xr<x>     Set the linker's rlink-path to <x> (needed for cross compile, see the ld manual for more information) (BeOS, Linux)
      -XR<x>     Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD, Linux, Mac OS, Solaris)
      -Xs        Strip all symbols from executable
      -XS        Try to link units statically (default, defines FPC_LINK_STATIC)
      -Xt        Link with static libraries (-static is passed to linker)
      -Xv        Generate table for Virtual Entry calls
      -XX        Try to smartlink units             (defines FPC_LINK_SMART)
 
  -?     Show this help
  -h     Shows this help without waiting
Second, with file asm64test1.pas containing the code you provided above after "Did you mean", I now get this:
hmm... I'm a bit lost with that. If you add:
Code: [Select]
uses SysUtils;
and -gl compiler option when compiling, what's the output?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #18 on: March 16, 2015, 10:07:28 am »
Those warnings probably mean you load global variables directly, while you should load them over %RIP.

Always make a pascal equivalent of your code, and check the output of the compiler. Then you would see how the compiler access variables.

Rick314

  • New Member
  • *
  • Posts: 28
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #19 on: March 16, 2015, 07:36:28 pm »
$ fpc -h
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.1.1 [2015/03/12] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
/mnt/LinuxShared/fpc/fpc [options] <inputfile> [options]
 Only options valid for the default or selected platform are listed.
 Put + after a boolean switch option to enable it, - to disable it.
...
  -P<x>  Target CPU / compiler related options:
      -PB        Show default compiler binary
      -PP        Show default target cpu
      -P<x>      Set target CPU (arm,avr,i386,jvm,m68k,mips,mipsel,powerpc,powerpc64,sparc,x86_64)

...
My "fpc -h" does not list -P, yet -P definitely works for me. This seems like a documentation error. Also notice I am executing "fpc" but my 3rd line says "ppc386.exe". This also seems like a documentation error. Here is my "fpc -h" output, just for interest:

C> fpc -h
Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
C:\FPC\2.6.4\bin\i386-Win32\ppc386.exe [options] <inputfile> [options]
Put + after a boolean switch option to enable it, - to disable it
...
  -O<x>  Optimizations:
      -O-        Disable optimizations
      -O1        Level 1 optimizations (quick and debugger friendly)
      -O2        Level 2 optimizations (-O1 + quick optimizations)
      -O3        Level 3 optimizations (-O2 + slow optimizations)
      -Oa<x>=<y> Set alignment
      -Oo[NO]<x> Enable or disable optimizations, see fpc -i for possible values
      -Op<x>     Set target cpu for optimizing, see fpc -i for possible values
      -OW<x>     Generate whole-program optimization feedback for optimization <x>, see fpc -i for possible values
      -Ow<x>     Perform whole-program optimization <x>, see fpc -i for possible values
      -Os        Optimize for size rather than speed
  -pg    Generate profile code for gprof (defines FPC_PROFILE)
  -R<x>  Assembler reading style:
      -Rdefault  Use default assembler for target
      -Ratt      Read AT&T style assembler
      -Rintel    Read Intel style assembler
...

But I want to focus on the needs expressed in my original post.

I'm a bit lost with that. If you add: uses SysUtils; and -gl compiler option when compiling, what's the output?
I noticed the code you provided flipped Quotient (RAX) with Remainder (RDX) so I fixed that. I also changed the Dividend so it has a non-0 remainder, added "uses SysUtils;", and saved in file asm64test2.pas:
Code: [Select]
{$asmmode intel}
uses
  SysUtils;
var
  HiDividend,LoDividend,Divisor,Quotient,Remainder: Int64;
begin
  HiDividend := $0000000000000001;
  LoDividend := $1100000000000017;
  Divisor := $10;
  asm
    MOV RDX,HiDividend
    MOV RAX,LoDividend
    DIV Divisor
    MOV Quotient,RAX
    MOV Remainder,RDX
  end ['RAX','RDX'];
  WriteLn(HexStr(Quotient,16));  { 1110000000000001 expected }
  WriteLn(HexStr(Remainder,16)); { 0000000000000007 expected }
end.

C> fpc -Px86_64 asm64test2
Free Pascal Compiler version 2.6.4 [2014/03/06] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling asm64test2.pas
Linking asm64test2.exe
asm64test2.pas(19,1) Warning: Object file "asm64test2.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_hidividend".
asm64test2.pas(19,1) Warning: Object file "asm64test2.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_divisor".
asm64test2.pas(19,1) Warning: Object file "asm64test2.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_remainder".
19 lines compiled, 0.1 sec , 73104 bytes code, 19268 bytes data
3 warning(s) issued

C> asm64test2
An unhandled exception occurred at $0000000100001553 :EDivByZero : Division by zero
  $0000000100001553

Using -gl:

C> fpc -Px86_64 -gl asm64test2
Free Pascal Compiler version 2.6.4 [2014/03/06] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling asm64test2.pas
Linking asm64test2.exe
asm64test2.pas(19,1) Warning: Object file "asm64test2.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_hidividend".
asm64test2.pas(19,1) Warning: Object file "asm64test2.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_divisor".
asm64test2.pas(19,1) Warning: Object file "asm64test2.o" contains 32-bit absolute relocation to symbol ".bss.n_u_p$program_remainder".
19 lines compiled, 0.10 sec , 81360 bytes code, 19444 bytes data
3 warning(s) issued

C> asm64test2
1110000000000001
0000000000000007

It works! But I am very confused and not done. The -gl option (generate debug information, use line info unit) changes execution from divide by zero (?!) to no runtime errors?! Why is "uses SysUtils;" required? How do I get rid of the 3 warnings? What does "you should load them over %RIP" from marcov mean?
« Last Edit: March 16, 2015, 07:40:40 pm by Rick314 »

Laksen

  • Hero Member
  • *****
  • Posts: 734
    • J-Software
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #20 on: March 16, 2015, 08:54:26 pm »
64bit executables on Windows require RIP relative addressing for global variables and other stuff.

HiDividend and all the other variables are global in the example you used. You don't use RIP relative addressing to get them, hence the linker complains that you only have direct 32-bit addresses. So your program works on your computer, but if loaded into a virtual address space above 4GB's it would crash.

Rick314

  • New Member
  • *
  • Posts: 28
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #21 on: March 17, 2015, 02:58:06 am »
OK, I have something that works in file asm64test3.pas:
Code: [Select]
{$asmmode intel}

procedure Div128(MSDividend : QWord; LSDividend : QWord; Divisor : QWord;
                 var Quotient : QWord; var Remainder : QWord);
{ Find MSDividend:LSDividend div Divisor -> Quotient rem Remainder, }
{ assuming MSDividend < Divisor }
begin
   asm
      mov rdx,MSDividend
      mov rax,LSDividend       { rdx:rax = 128-bit dividend }
      div Divisor              { 128bits div 64bits = 64bits rem 64bits }
      mov rdi,Quotient         { rdi = ptr to Quotient }
      mov qword ptr [rdi],rax  { Quotient = rdx:rax div Divisor }
      mov rdi,Remainder        { rdi = ptr to Remainder }
      mov qword ptr [rdi],rdx  { Remainder = rdx:rax mod Divisor }
   end ['rdx','rax','rdi'];
end;


var
   _MSDividend, _LSDividend, _Divisor, _Quotient, _Remainder: QWord;

begin { main }
   _MSDividend := $0000000000000001;
   _LSDividend := $1100000000000017;
   _Divisor := $10;

   Div128(_MSDividend, _LSDividend, _Divisor, _Quotient, _Remainder);

   WriteLn(HexStr(_Quotient,16));  { 1110000000000001 expected }
   WriteLn(HexStr(_Remainder,16)); { 0000000000000007 expected }
end.
It compiles and runs with no errors, producing the desired output:

C> fpc -Px86_64  asm64test3
Free Pascal Compiler version 2.6.4 [2014/03/06] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling asm64test3.pas
Linking asm64test3.exe
32 lines compiled, 0.0 sec , 30304 bytes code, 1748 bytes data

C> asm64test3
1110000000000001
0000000000000007

But when I try to see the generated assembly code I get errors and an aborted compile:

C> fpc -Px86_64 -al asm64test3
Free Pascal Compiler version 2.6.4 [2014/03/06] for x86_64
Copyright (c) 1993-2014 by Florian Klaempfl and others
Note: Switching assembler to default source writing assembler
Target OS: Win64 for x64
Compiling asm64test3.pas
Assembling program
asm64test3.pas(33) Error: Assembler x86_64-win64-ml64.exe not found, switching to external assembling
asm64test3.pas(33) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: C:\FPC\2.6.4\bin\i386-Win32\ppcrossx64.exe returned an error exitcode (normal if you did notspecify a source file to be compiled)

How can I get a successful compile and see the generated assembly code? I see "x86_64-win64-ml64.exe not found" and indeed it is not in my C:\FPC\2.6.4\bin\i386-win32\ directory. Was it left out of the fpc-2.6.4.x86_64-win64.exe distribution by mistake, or is the error incorrect, or what?

Do you have any improvement suggestions for the "asm ... end" block?
« Last Edit: March 17, 2015, 02:59:49 am by Rick314 »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #22 on: March 17, 2015, 10:21:20 am »
But when I try to see the generated assembly code I get errors and an aborted compile:

C> fpc -Px86_64 -al asm64test3
pass also -s. Actually, at this point, the assembly file should already be generated with .s extension.

Rick314

  • New Member
  • *
  • Posts: 28
Re: Free Pascal and Intel Core 64-bit assembly language
« Reply #23 on: March 17, 2015, 05:09:07 pm »
SOLVED and many thanks to all that contributed.  :)

 

TinyPortal © 2005-2018