Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2000-10

Linking with external ASM files (compiled by NASM)

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sebastian Schuberth

Hello guys!

I'm tring to link an external ASM program into a Free Pascal unit:

--8<--(test.asm)--

section .text
bits 32

global test_

test_:
xor eax,eax
ret

--8<--(test.asm)--

To compile the ASM file I use: "nasm -f coff -o test_asm.o test.asm"

--8<--(test.pas)--

Unit Test;
Interface
Procedure a;
Implementation
{$L TEST_ASM.O}
Procedure test_; External;

Procedure a; Assembler;
Asm
{ do some stuff }
call test_
{ do some stuff }
End;

End.

--8<--(test.pas)--

And a main program:

--8<--(main.pas)--

Program Main;
Uses
  Test;
Begin
  a;
End.

--8<--(main.pas)--

When executing "ppc386 main.pas" the linker always complains that "TEST_" would be
an undefined reference. Since "TEST_" is written uppercase I already tried to define
the test_ procedure within the ASM file uppercase, too, but it didn't help. What am
I doing wrong?

Sebastian Schuberth
Pierre Muller
to Sebastian Schuberth

At 15:46 04/10/00 , vous avez écrit:

Show quoted text 65 lines
Hello guys! I'm tring to link an external ASM program into a Free Pascal unit: --8<--(test.asm)-- section .text bits 32 global test_ test_: xor eax,eax ret --8<--(test.asm)-- To compile the ASM file I use: "nasm -f coff -o test_asm.o test.asm" --8<--(test.pas)-- Unit Test; Interface Procedure a; Implementation {$L TEST_ASM.O} Procedure test_; External; Procedure a; Assembler; Asm { do some stuff } call test_ { do some stuff } End; End. --8<--(test.pas)-- And a main program: --8<--(main.pas)-- Program Main; Uses Test; Begin a; End. --8<--(main.pas)-- When executing "ppc386 main.pas" the linker always complains that "TEST_" would be an undefined reference. Since "TEST_" is written uppercase I already tried to define the test_ procedure within the ASM file uppercase, too, but it didn't help. What am I doing wrong?
   You should use
   procedure _test; external name '_test';
or
   procedure AnyNameYouLike;external name '_test';

asm
call AnyNAMEYouLike
end;

Free Pascal is a Pascal compiler and as such essentially case insensitive! A other (but discouraged) solution would be to use -Rdirect switch together with -Aas !