Sign in Join

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

Mailing lists / fpc-pascal / 2010-08

inline asm in fpc progran

12 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Nataraj S Narayan

Hi

May I have some help in this code ? I am on arm-linux-uclibc. Compiling using :-

# ppcrossarm -MObjFPC -TLinux -Parmv5 -gl -Xd -Xs -l -darm -XParm-unknown-linux-uclibcgnueabi- -CfSOFT -CaEABI -darm -gl -O- -CpARMV5 -uUSE_LOCALIZE -Fu/usr/local/lib/fpc/2.5.1/units/arm-linux/* -Fl$/usr/staging/usr/arm-unknown-linux-uclibcgnueabi/lib -FL/usr/staging/lib/ld-uClibc.so.0 -XR/usr/staging -Fl/usr/staging/lib -Fl/usr/staging/usr/lib -k"--sysroot=/usr/staging" -k"-rpath-link=/usr/staging/usr/arm-unknown-linux-uclibcgnueabi/lib/" main1.pas

Program main;
function fact(x : integer):integer;assembler;

label

    loop;

asm
.text
.align 2
mov r1,r0
mov r2,#1
loop:
mul r3,r2,r1
mov r2,r3
subs r1,r1,#1
cmp r1,#0
bgt loop

MOV r0,r2
MOV pc,lr
end;

var
i:integer;
begin
 for i:=1 to 10 do
      writeln('factorial',i,fact(i));
 end.

This compiles and links. But wont execute on Arm target (at91sam9263ek). Just waits endless. The equivalent C code linked to the external assembled code works well.

regards

Nataraj

Jonas Maebe
to Nataraj S Narayan
Nataraj S Narayan wrote 5 lines
This compiles and links. But wont execute on Arm target (at91sam9263ek). Just waits endless. The equivalent C code linked to the external assembled code works well.

You probably need the "nostackframe" directive, or remove the "mov pc,lr" at the end.

Compile the code with -al, compile equivalent Pascal code with -al and look at the differences in the generated ".s" files.

Jonas

Nataraj S Narayan
to Jonas Maebe

Jonas

I changed the kernel to old 2.6.30 and the code works on the Arm target!

That kernel has been compiled with CONFIG_OABI_COMPAT=y. Newer kernels dont show this option, only EABI.

Also my ppcrossarm is :-

Free Pascal Compiler version 2.5.1 [2010/07/28] for arm Copyright (c) 1993-2009 by Florian Klaempfl

What do you make of it? Compile a new ppcrossarm and try it?

regards

Nataraj

Jonas Maebe wrote 21 lines
On 20 Aug 2010, at 09:41, Nataraj S Narayan wrote: This compiles and links. But wont execute on Arm target (at91sam9263ek). > Just waits endless. The equivalent C code linked to the external > assembled > code works well. > You probably need the "nostackframe" directive, or remove the "mov pc,lr" at the end. Compile the code with -al, compile equivalent Pascal code with -al and look at the differences in the generated ".s" files. Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Nataraj S Narayan
Nataraj S Narayan wrote 23 lines
On Fri, Aug 20, 2010 at 2:38 PM, Jonas Maebe < >wrote: > You probably need the "nostackframe" directive, or remove the "mov > pc,lr" > at the end. > > Compile the code with -al, compile equivalent Pascal code with -al > and look > at the differences in the generated ".s" files. I changed the kernel to old 2.6.30 and the code works on the Arm target! That kernel has been compiled with CONFIG_OABI_COMPAT=y. Newer kernels dont show this option, only EABI. Also my ppcrossarm is :- Free Pascal Compiler version 2.5.1 [2010/07/28] for arm Copyright (c) 1993-2009 by Florian Klaempfl What do you make of it?

That you did not reply to the suggestions I made in my previous message. Please say what you did and what happened, even if it didn't work. It's not nice to spend time on trying to help someone, if that person then simply ignores what you write and replies with something completely different.

The EABI requires that the stack is always aligned to 8 bytes on entry/ exit of subroutines, and you probably mess up the alignment with the manually inserted return instruction.

Also, make sure that you compiled an EABI cross-compiler (ensure that - dFPC_ARMEL is part of the OPT setting of the "make" invocation used to compile FPC).

Jonas

Nataraj S Narayan
to Jonas Maebe

Jonas

I was expecting exactly this response from you.

I did'nt ask you to volunteer to help me. If you don't find time, or feel it wasting your time, let somebody else do it. Issue is very much real and i tried out your suggestions without any use.

regards

Nataraj

"Someday they gonna tell ya there was this clone of FreePascal, And it was called Delphi....

Till then, we shan't be cocky and vain"

Jonas Maebe wrote 49 lines
On 20 Aug 2010, at 15:00, Nataraj S Narayan wrote: > On Fri, Aug 20, 2010 at 2:38 PM, Jonas Maebe < > >wrote: > >> You probably need the "nostackframe" directive, or remove the "mov pc,lr" >> >> at the end. >> >> Compile the code with -al, compile equivalent Pascal code with -al and >> look >> at the differences in the generated ".s" files. >> > > I changed the kernel to old 2.6.30 and the code works on the Arm target! > > That kernel has been compiled with CONFIG_OABI_COMPAT=y. Newer kernels > dont > show this option, only EABI. > > Also my ppcrossarm is :- > > Free Pascal Compiler version 2.5.1 [2010/07/28] for arm > Copyright (c) 1993-2009 by Florian Klaempfl > > What do you make of it? > That you did not reply to the suggestions I made in my previous message. Please say what you did and what happened, even if it didn't work. It's not nice to spend time on trying to help someone, if that person then simply ignores what you write and replies with something completely different. The EABI requires that the stack is always aligned to 8 bytes on entry/exit of subroutines, and you probably mess up the alignment with the manually inserted return instruction. Also, make sure that you compiled an EABI cross-compiler (ensure that -dFPC_ARMEL is part of the OPT setting of the "make" invocation used to compile FPC). Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Michael Van Canneyt
to Nataraj S Narayan

All Jonas wanted to say was that you didn't report on his suggestions. How can he help further if he doesn't know the result of his previous suggestion ?

Giving help is in the first place diagnosing. We can't offer help if the diagnose result is not known or incomplete.

Michael.

Nataraj S Narayan wrote 73 lines
Jonas I was expecting exactly this response from you. I did'nt ask you to volunteer to help me. If you don't find time, or feel it wasting your time, let somebody else do it. Issue is very much real and i tried out your suggestions without any use. regards Nataraj "Someday they gonna tell ya there was this clone of FreePascal, And it was called Delphi.... Till then, we shan't be cocky and vain" On Fri, Aug 20, 2010 at 6:51 PM, Jonas Maebe wrote: > > On 20 Aug 2010, at 15:00, Nataraj S Narayan wrote: > >> On Fri, Aug 20, 2010 at 2:38 PM, Jonas Maebe < >>> wrote: >> >>> You probably need the "nostackframe" directive, or remove the "mov pc,lr" >>> >>> at the end. >>> >>> Compile the code with -al, compile equivalent Pascal code with -al and >>> look >>> at the differences in the generated ".s" files. >>> >> >> I changed the kernel to old 2.6.30 and the code works on the Arm target! >> >> That kernel has been compiled with CONFIG_OABI_COMPAT=y. Newer kernels >> dont >> show this option, only EABI. >> >> Also my ppcrossarm is :- >> >> Free Pascal Compiler version 2.5.1 [2010/07/28] for arm >> Copyright (c) 1993-2009 by Florian Klaempfl >> >> What do you make of it? >> > > That you did not reply to the suggestions I made in my previous message. > Please say what you did and what happened, even if it didn't work. It's not > nice to spend time on trying to help someone, if that person then simply > ignores what you write and replies with something completely different. > > The EABI requires that the stack is always aligned to 8 bytes on entry/exit > of subroutines, and you probably mess up the alignment with the manually > inserted return instruction. > > Also, make sure that you compiled an EABI cross-compiler (ensure that > -dFPC_ARMEL is part of the OPT setting of the "make" invocation used to > compile FPC). > > > > Jonas > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
patspiper
to Nataraj S Narayan: Jonas I was expecting exactly this response from you. I did'nt ask you to volunteer to…
Nataraj S Narayan wrote 11 lines
Jonas I was expecting exactly this response from you. I did'nt ask you to volunteer to help me. If you don't find time, or feel it wasting your time, let somebody else do it. Issue is very much real and i tried out your suggestions without any use. regards Nataraj
Nataraj S Narayan wrote
May I have some help in this code ? I am on arm-linux-uclibc. Compiling using :-

If you are looking for paid help, please mention it clearly in your post. Otherwise, you are asking for volunteer help, and Jonas did just that. This is not the way to thank him.

Nataraj S Narayan
to patspiper

Hi

I don't NEED a help, paid or unpaid. As for the regular arm software development I am already using stable and good tools like C++, Ruby, Python. Fpc/Lazarus is more of a hobby or a kind nostalgia about the good old Delphi. Of course, if it works well, quite good. As for volunteering, I too am putting my 2 cents in trying out the compiler and tools and reporting whatever I find. So its mutual help, if you call it. Again , it is simple as "Take or leave it" mutually.

I am an application developer, I don't do compilers or OS. If there is a problem that a simple C program calling a factorial code written in Arm assembly works well, and the equivalent fpc program calling the same routine works only in a kind of kernels which support OABI, there is definitely a problem with the compiler, and hence no need to try any hanky pranky on the assembler code. I would rather come straight to the issue of fpc working only in kernels being compiled for OABI.

That's what I did - trying to save valuable time for both of us.

This issue has been raised by me before with Mr.Jonas , hope he remembers, in this thread:-

regards

Nataraj

"Someday they gonna tell ya there was this clone of FreePascal, And it was called Delphi.... Till then, we shan't be cocky and vain"

patspiper wrote 29 lines
On 08/21/2010 07:44 AM, Nataraj S Narayan wrote: > Jonas > > I was expecting exactly this response from you. > > I did'nt ask you to volunteer to help me. If you don't find time, or feel > it wasting your time, let somebody else do it. Issue is very much real and i > tried out your suggestions without any use. > > regards > > Nataraj > On 08/20/2010 10:41 AM, Nataraj S Narayan wrote: > May I have some help in this code ? I am on arm-linux-uclibc. Compiling > using :- > If you are looking for paid help, please mention it clearly in your post. Otherwise, you are asking for volunteer help, and Jonas did just that. This is not the way to thank him. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
patspiper
to Nataraj S Narayan
Nataraj S Narayan wrote
Hi I don't NEED a help, paid or unpaid.

Your first email mentions explicitly the need for help:

Nataraj S Narayan wrote 15 lines
Hi May I have some help in this code ? I am on arm-linux-uclibc. Compiling using :- <snip> As for the regular arm software development I am already using stable and good tools like C++, Ruby, Python. Fpc/Lazarus is more of a hobby or a kind nostalgia about the good old Delphi. Of course, if it works well, quite good. As for volunteering, I too am putting my 2 cents in trying out the compiler and tools and reporting whatever I find. So its mutual help, if you call it. Again , it is simple as "Take or leave it" mutually.

Most of the list threads are for people asking for help, and this is perfectly normal.
Most of the replies are from volunteers, and this is normal too. Many have opened threads asking for help on one hand, and on the other volunteered their help within this community one way or another.

If you have volunteered any help, no matter how small it is, it is for the benefit of the FPC/Lazarus community.

Jonas has replied to your op, and has asked you in a following post to report your feedback on his suggestions. He simply is not able to continue his diagnostics without this feedback.

Did you try his suggestions? If so, report your findings so that he can continue his diagnosis.

Show quoted text 22 lines
I am an application developer, I don't do compilers or OS. If there is a problem that a simple C program calling a factorial code written in Arm assembly works well, and the equivalent fpc program calling the same routine works only in a kind of kernels which support OABI, there is definitely a problem with the compiler, and hence no need to try any hanky pranky on the assembler code. I would rather come straight to the issue of fpc working only in kernels being compiled for OABI. That's what I did - trying to save valuable time for both of us. This issue has been raised by me before with Mr.Jonas , hope he remembers, in this thread:- regards Nataraj "Someday they gonna tell ya there was this clone of FreePascal, And it was called Delphi.... Till then, we shan't be cocky and vain"
Nataraj S Narayan
to Jonas Maebe: That you did not reply to the suggestions I made in my previous message. Please say what…

Hi Jonas

I tried a very elementary code on arm-linux-uclibc, compiled using "ppcrossarm -TLinux -darm ttt3.pas -CfSOFT -XParm-linux- -XR/cdrom"

program kuraj;
begin
writeln('Hooua');
end.

The asm listing using -al is here: - http://pastebin.com/CG9i0x3z

It dont work in the normal EABI kernel but works on OABI compat one.

I got ppcrossarm using :-
gmake distclean crosszipinstall CPU_TARGET=arm OS_TARGET=linux CROSSOPT='-CfSOFT -darm -dFPC-ARMEL -gl' FPC=/usr/local/lib/fpc/2.5.1/ppc386

warm regards

Nataraj

Jonas Maebe wrote 49 lines
On 20 Aug 2010, at 15:00, Nataraj S Narayan wrote: > On Fri, Aug 20, 2010 at 2:38 PM, Jonas Maebe < > >wrote: > >> You probably need the "nostackframe" directive, or remove the "mov pc,lr" >> >> at the end. >> >> Compile the code with -al, compile equivalent Pascal code with -al and >> look >> at the differences in the generated ".s" files. >> > > I changed the kernel to old 2.6.30 and the code works on the Arm target! > > That kernel has been compiled with CONFIG_OABI_COMPAT=y. Newer kernels > dont > show this option, only EABI. > > Also my ppcrossarm is :- > > Free Pascal Compiler version 2.5.1 [2010/07/28] for arm > Copyright (c) 1993-2009 by Florian Klaempfl > > What do you make of it? > That you did not reply to the suggestions I made in my previous message. Please say what you did and what happened, even if it didn't work. It's not nice to spend time on trying to help someone, if that person then simply ignores what you write and replies with something completely different. The EABI requires that the stack is always aligned to 8 bytes on entry/exit of subroutines, and you probably mess up the alignment with the manually inserted return instruction. Also, make sure that you compiled an EABI cross-compiler (ensure that -dFPC_ARMEL is part of the OPT setting of the "make" invocation used to compile FPC). Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jeppe Johansen
to Nataraj S Narayan

Fpc should be compiled with -dFPC-ARMEL in OPT, not CROSSOPT

Nataraj S Narayan wrote 88 lines
Hi Jonas I tried a very elementary code on arm-linux-uclibc, compiled using "ppcrossarm -TLinux -darm ttt3.pas -CfSOFT -XParm-linux- -XR/cdrom" program kuraj; begin writeln('Hooua'); end. The asm listing using -al is here: - http://pastebin.com/CG9i0x3z It dont work in the normal EABI kernel but works on OABI compat one. I got ppcrossarm using :- gmake distclean crosszipinstall CPU_TARGET=arm OS_TARGET=linux CROSSOPT='-CfSOFT -darm -dFPC-ARMEL -gl' FPC=/usr/local/lib/fpc/2.5.1/ppc386 warm regards Nataraj On Fri, Aug 20, 2010 at 6:51 PM, Jonas Maebe < > wrote: On 20 Aug 2010, at 15:00, Nataraj S Narayan wrote: On Fri, Aug 20, 2010 at 2:38 PM, Jonas Maebe < >wrote: You probably need the "nostackframe" directive, or remove the "mov pc,lr" at the end. Compile the code with -al, compile equivalent Pascal code with -al and look at the differences in the generated ".s" files. I changed the kernel to old 2.6.30 and the code works on the Arm target! That kernel has been compiled with CONFIG_OABI_COMPAT=y. Newer kernels dont show this option, only EABI. Also my ppcrossarm is :- Free Pascal Compiler version 2.5.1 [2010/07/28] for arm Copyright (c) 1993-2009 by Florian Klaempfl What do you make of it? That you did not reply to the suggestions I made in my previous message. Please say what you did and what happened, even if it didn't work. It's not nice to spend time on trying to help someone, if that person then simply ignores what you write and replies with something completely different. The EABI requires that the stack is always aligned to 8 bytes on entry/exit of subroutines, and you probably mess up the alignment with the manually inserted return instruction. Also, make sure that you compiled an EABI cross-compiler (ensure that -dFPC_ARMEL is part of the OPT setting of the "make" invocation used to compile FPC). Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jeppe Johansen
to Jeppe Johansen

Err, that should be -dFPC_ARMEL of course

Jeppe Johansen wrote 96 lines
Fpc should be compiled with -dFPC-ARMEL in OPT, not CROSSOPT Den 26-08-2010 07:10, Nataraj S Narayan skrev: > Hi Jonas > > > I tried a very elementary code on arm-linux-uclibc, compiled using > "ppcrossarm -TLinux -darm ttt3.pas -CfSOFT -XParm-linux- -XR/cdrom" > > program kuraj; > begin > writeln('Hooua'); > end. > > > The asm listing using -al is here: - http://pastebin.com/CG9i0x3z > > It dont work in the normal EABI kernel but works on OABI compat one. > > I got ppcrossarm using :- > gmake distclean crosszipinstall CPU_TARGET=arm OS_TARGET=linux > CROSSOPT='-CfSOFT -darm -dFPC-ARMEL -gl' > FPC=/usr/local/lib/fpc/2.5.1/ppc386 > > > warm regards > > Nataraj > > On Fri, Aug 20, 2010 at 6:51 PM, Jonas Maebe > < > wrote: > > > On 20 Aug 2010, at 15:00, Nataraj S Narayan wrote: > > On Fri, Aug 20, 2010 at 2:38 PM, Jonas Maebe > < > >wrote: > > You probably need the "nostackframe" directive, or remove > the "mov pc,lr" > > at the end. > > Compile the code with -al, compile equivalent Pascal code > with -al and look > at the differences in the generated ".s" files. > > > I changed the kernel to old 2.6.30 and the code works on the > Arm target! > > That kernel has been compiled with CONFIG_OABI_COMPAT=y. > Newer kernels dont > show this option, only EABI. > > Also my ppcrossarm is :- > > Free Pascal Compiler version 2.5.1 [2010/07/28] for arm > Copyright (c) 1993-2009 by Florian Klaempfl > > What do you make of it? > > > That you did not reply to the suggestions I made in my previous > message. Please say what you did and what happened, even if it > didn't work. It's not nice to spend time on trying to help > someone, if that person then simply ignores what you write and > replies with something completely different. > > The EABI requires that the stack is always aligned to 8 bytes on > entry/exit of subroutines, and you probably mess up the alignment > with the manually inserted return instruction. > > Also, make sure that you compiled an EABI cross-compiler (ensure > that -dFPC_ARMEL is part of the OPT setting of the "make" > invocation used to compile FPC). > > > > Jonas > _______________________________________________ > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > _______________________________________________ > fpc-pascal maillist > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal