[fpc-pascal]Linking with external ASM files (compiled by NASM)
Pierre Muller
pierre at freepascal.org
Wed Oct 4 16:03:23 CEST 2000
At 15:46 04/10/00 , vous avez écrit:
>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 !
More information about the fpc-pascal
mailing list