Free Pascal target Atari

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Post Reply
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Tue Jan 25, 2022 6:47 pm I am wondering if the fp sources are needed for building hello.pas otherwise I can't see where syspara.inc without come from.
No, FPC's or the RTL's sources aren't needed to compile programs, of course. If the compiler seeks for syspara.inc, it means it already started to (re)compile a system unit, so it found a system.pp. Don't be in the rtl/atari directory, when trying to compile a hello world. :) Or don't specify the path to that source. Specify the path to the pre-built *.ppu files instead using the -Fu argument.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I am going to concentrate on getting FP to run natively on the Milan060 under Mint.

1. installed FP binary on a FAT32 long filename partition, f:\Applications\fpascal
2. installed the vlink binary from http://sun.hasenbraten.de/vlink/bin/cur/vlink_MiNT.zip in /usr/bin
3. currently building vasm from http://sun.hasenbraten.de/vasm/release/vasm.tar.gz
with make CPU=m68k SYNTAX=std (I didn't spot the binary attached above).
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I moved the hello.pas out of the bin/atari folder but then I get other issues with file not found (-33), even with the fpascal folder added to the path.

# pwd
/f/Applications/fpascal

# /f/Applications/fpascal/bin/atari/fpc.ttp -Tatari -va hello.pas
Error: ppc68k.ttp can't be executed, error message: Failed to execute "ppc68k.ttp -Tatari -va hello.pas", error code: -33


I'm missing something.
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Tue Jan 25, 2022 10:23 pm # /f/Applications/fpascal/bin/atari/fpc.ttp -Tatari -va hello.pas
Error: ppc68k.ttp can't be executed, error message: Failed to execute "ppc68k.ttp -Tatari -va hello.pas", error code: -33
The "fpc" binary is just a compiler frontend, mostly useful if you're have multiple versions or CPU targets installed. You're safe to call "ppc68k.ttp" directly instead. This issue is because I never implemented environmental variables support (are they even a thing on TOS?) for Atari, neither querying the path, so the compiler can't see what's in the path. An alternative solution or workaround for now is using the -FD argument, to tell the compiler with an absolute path where it finds various external tools and utilities. (That applies to vasm/vlink too.) ... Maybe the first thing to implement going forward? ;)

On a related note, I wonder if I should keep the TOS support separate and just go with a separate MiNT target. I never used MiNT, and I barely looked into the API, but my vision was, I want to have a safe set of libs which will work even on the smallest Atari ST with TOS and single task. But input is very welcomed if that's only duplicated work, or actually makes sense.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

OK, so I just pushed a few important fixes to the FPC main branch regarding Atari:
  • fixed the TOS program flags problem as reported by Thorsten on fpc-devel (Thanks!)
  • introduced a new platform specific parameter -WF, to allow specifying custom program flags, if needed (default: 7)
  • moved the TOS support to default the 68000, use vlink and vasm by default
  • got rid of some old .as assembler source file, which was no longer even in use, so now it's possible to build the Atari RTL without GNU binutils.
  • disabled the so-called "tinyheap" feature of the RTL, now TOS now defaults to the regular the regular heap manager. This increases memory use somewhat, but the compiler itself doesn't work with tinyheap for some reason (to be debugged later).
Whatever you're trying, please make sure you use the current main branch sources or newer (as of the writing of this post). Now the compiler works for me at least with EmuTOS and Hatari. On the screenshot vasm/vlink binaries are release binaries from Frank Wille's site, units/atari/rtl contains the *.o and *.ppu files from an rtl cross-build, ppc68k.ttp was also cross-built, but at least it can build a Hello, World! on EmuTOS.
current FPC on EmuTOS
You do not have the required permissions to view the files attached to this post.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

ChainQ wrote: Tue Jan 25, 2022 8:49 pm He's called Volker Barthelmann
Oops, right.
There are vasm binaries with std syntax available for TOS/MiNT, on Frank Wille's page
Oh, i somehow missed them. But i bet they are compiled by vc, using vclib. Maybe does not matter much in this case, but mintlib usually support MiNT much better.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

ChainQ wrote: Tue Jan 25, 2022 10:48 pm On a related note, I wonder if I should keep the TOS support separate and just go with a separate MiNT target.
There is normally no need to distinguish the two. There are of course functions in MiNT that are not supported in TOS, but its up to the user (and maybe partly the system libraries) to handle that. If you do it properly, you can run the same binary both on TOS and MiNT. Using separate targets would be confusing, and require the user to also compile his programs for both targets.

BTW, same is also true for vlink which comes in two flavors. The only real difference is that the *_MiNT executable use -baoutmint by default, which creates a different symbol table that does not have the ugly 8-character limit of the old tos format.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

ChainQ wrote: Tue Jan 25, 2022 10:48 pm
PeterS wrote: Tue Jan 25, 2022 10:23 pm # /f/Applications/fpascal/bin/atari/fpc.ttp -Tatari -va hello.pas
Error: ppc68k.ttp can't be executed, error message: Failed to execute "ppc68k.ttp -Tatari -va hello.pas", error code: -33
The "fpc" binary is just a compiler frontend, mostly useful if you're have multiple versions or CPU targets installed. You're safe to call "ppc68k.ttp" directly instead.
I did try that as well but the build stopped while looking for the system.ppu.

I think I will delete the installation and try again. I may have to work out how to cross compile so I can try the new build.
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Tue Jan 25, 2022 10:23 pm I did try that as well but the build stopped while looking for the system.ppu.
Caused by missing or incorrect -Fu parameter, to specify unit paths. There isn't anything magic in this. The compiler needs to know a couple of paths, one is to the unit files (-Fu), and another one to the tools to use (-FD parameter) and then it should work. See the ppc68k command line on my example screenshot. That really has everything you need. (The * at the end of the -Fu parameter says, "look into every directory, within this directory", so you don't need to specify every directory one-by-one in this case.)
PeterS wrote: Tue Jan 25, 2022 10:23 pm I think I will delete the installation and try again. I may have to work out how to cross compile so I can try the new build.
If it helps, Marcus Sackrow's FPC/Amiga buildsystem also provides "raw"/"nightly" Atari builds. The archive on this link is updated regularly with the newest build: http://build.alb42.de/fpcbin/fpc-3.3.1.atari.tar.gz

You still need to supplement this archive with vasm/vlink, but otherwise it has a working Atari-native compiler, and all the unit files in binary, so should be good enough for some initial testing and work.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I've installed the 3.3.1 build that you linked to above and the vasm that Thorsten attached.

No matter what I do it cannot find the vasm binary. I even copied into the bin/atari folder.


# bin/atari/ppc68k.ttp -l -vaeiw -O2 -Xs -FDbin -Fuunits/atari/* hello.pas

[12.000] Searching file hello.pas... found
[12.000] Assembling hello
[12.000] Searching file bin/vasmm68k_std.ttp... not found
[12.000] Searching file vasmm68k_std.ttp... not found
[12.000] Searching file vasmm68k_std.ttp... not found
[12.000] hello.pas(4,24) Error: Assembler vasmm68k_std.ttp not found, switching to external assembling
[12.000] hello.pas(4,24) Fatal: There were 1 errors compiling module, stopping
[12.000] Fatal: Compilation aborted
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I moved the vasm bin into the freepascal folder and it has found it.

[10.000] Searching file hello.pas... found
[12.000] Assembling hello
[12.000] Searching file bin/vasmm68k_std.ttp... not found
[12.000] Searching file vasmm68k_std.ttp... found
[12.000] Using assembler: vasmm68k_std.ttp
[12.000] Executing "vasmm68k_std.ttp" with command line "-quiet -elfregs -gas -Felf -m68000 -o hello.o hello.s"

fatal error 17: could not initialize output module <uunits/atari/*>
aborting...
[12.000] hello.pas(4,24) Error: Error while assembling exitcode 1
[12.000] hello.pas(4,24) Fatal: There were 2 errors compiling module, stopping
[12.000] Fatal: Compilation aborted
User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2900
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Free Pascal target Atari

Post by charles »

I'm just taking a wild stab because I quickly looked at this thread but is it having trouble locating our files due to our padded path and hierarchy subdirectories

just a thought...maybe not?
The radioactive half-life : )
Atari is a lifestyle,not a hobby.
HOLD ON ! ! ! Im printing unreadable characters ...!
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Wed Jan 26, 2022 7:34 pm fatal error 17: could not initialize output module <uunits/atari/*>
aborting...
This error message is _not_ from Free Pascal, but from vasm. It looks like somehow the called program inherits ppc68k's command line options, so "-Fuunits/atari/*" gets passed to vasm. I don't know why or how, it clearly doesn't happen on my setup, and there's no code in FPC do to so. -F option of vasm selects the output module, hence the error message.

Free Pascal uses the GEMDOS function pexec() to call the underlying program, maybe there's a bug there. The code is here:
https://gitlab.com/freepascal.org/fpc/s ... ls.pp#L486

Code: Select all

result:=gemdos_pexec(0,PChar(tmpPath),@pcmdline[0],nil);
If I can have an educated guess, this is somehow related to the fact that we pass "nil" (a.k.a. 0L) to pexec "env" there, and according to TosHyp documentation, that makes the child process inherit the parent's environment, which in this case must somehow include ARGV things, which FPC doesn't touch currently. Gonna guess that is the problem somehow. Maybe my vasm build which uses vclib (it's from Frank Wille's site) and not mintlib hides the problem?
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

OK, now I tried with Thorsten's vasm/vlink build from this topic on Hatari + EmuTOS, and it still works for me, however, since he seems to have used vasm nightly sources to build his vasm binary, instead of the release one, there are now some unwanted messages from the assembler, regarding some asm labels (see the screenshot below). Again, these come from vasm, and not Free Pascal. Since you're using a random vasm nightly sources build, the only things I can do are: 1., gonna report this problem to Frank Wille, so it's fixed before a new release. 2., advise you to use another assembler build, preferably not a random nightly but a release. :)
vasm issue screenshot
And then of course, input is still welcome regarding the above pexec problem.
You do not have the required permissions to view the files attached to this post.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

ChainQ wrote: Wed Jan 26, 2022 11:47 pm If I can have an educated guess, this is somehow related to the fact that we pass "nil" (a.k.a. 0L) to pexec "env" there, and according to TosHyp documentation, that makes the child process inherit the parent's environment, which in this case must somehow include ARGV things, which FPC doesn't touch currently.
Theoretically, that should not happen. mintlib should only use ARGV, when the command line length is set to 127, which does not happen in fpc. But i agree that the problem really looks like being caused by this.

1., gonna report this problem to Frank Wille
Oops. My bad. No, thats not a vasm problem. I was not using a nightly snapshot, but latest release 18l. But i added a debug printf somewhere that i forgot to remove.
And then of course, input is still welcome regarding the above pexec problem.
That will be gone if at least the startup code supports ARGV.
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

ThorstenOtto wrote: Thu Jan 27, 2022 6:06 am Oops. My bad. No, thats not a vasm problem. I was not using a nightly snapshot, but latest release 18l. But i added a debug printf somewhere that i forgot to remove.
No worries, at least there we have an explanation. And then after all it's good that I'm a slacker, and did not sent that email yet... ;)
And then of course, input is still welcome regarding the above pexec problem.
That will be gone if at least the startup code supports ARGV.
I don't see how, I mean ExecuteProcess code should still do the env copy itself and omit ARGV= (or add it's own depending on the command line length) no? BTW, I had a stab yesterday under EmuTOS (as I don't have a working FreeMint setup, and definitely no time to figure that one out now) to get something like this working. I tried to parse the env pointer in the basepage, but I only see a PATH= variable, with C:\ as value, and nothing else. Which is weird for multiple reasons, for example I added some more directories to the PATH (with the "path" command in EmuCON), but they don't seem to appear there. Neither can I see an ARGV= variable, which is double-weird, because if the thing is optional even on recent TOS remakes, then we can't reliably implement argv[0] (executable name). So I'm at a bit of a loss here.

Anyway, I'm sure going MiNT is a solution to all this, so never mind, I just have to figure out how to get it working in some kind of emu which doesn't kill my laptop, and how can I quickly iterate on testing binaries (shared folder with the host OS would be ideal).
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

You could do an aranym+afros installation to get Mint, it's relatively quick and painless.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

ChainQ wrote: Thu Jan 27, 2022 8:21 am I don't see how, I mean ExecuteProcess code should still do the env copy itself and omit ARGV=
No it does not have to remove ARGV, that's task of the startup module. But that does not happen currently, so if you use a shell that uses ARGV, and Pexec() is called with env=null, programs that are invoked from within fpc (or ppcm68k), like the assembler or linker, will see the ARGV that was passed from the shell. But as noted above, they should ignore it if the "normal" commandline does not indicate that ARGV is in use, but apparently something is going wrong there somewhere.
Neither can I see an ARGV= variable
That's because EmuCON does not use ARGV.
So I'm at a bit of a loss here.
Don't worry, i'll take care of that.
(shared folder with the host OS would be ideal).
For plain TOS, you can use Hatari for that. For Mint, you have to use ARAnyM, because MiNT gets in the way with Hatari's gemdos emulation. Vincent posted a video some time ago to get ARAnyM+MiNT running (that was for Windows, but its not much more difficult on linux). Only problem is that there are currently no daily snapshots available for aranym. There are also premade images available with some tools installed; you can still boot from that image, then add some host holder in the config file to share your data.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

Would it make a difference if I started it from the GEM ttp dialogue instead of using bash ?
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I was doubtful but it actually worked and it created hello.ttp
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

PeterS wrote: Thu Jan 27, 2022 10:14 am Would it make a difference if I started it from the GEM ttp dialogue instead of using bash ?
Depends on the desktop. I think bash always uses ARGV, regardless of commandline length. Some desktops try to be clever and only use ARGV when it is longer than 126 chars. But actually that isn't that clever, since without ARGV the ttp cannot get a reasonable value for argv[0].
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I'm using Thing. The good news is that it worked, the build window closes immediately which is a bit annoying.

I also tried higem.pas from the examples but that failed, unable to find aes.ppu

I'll investigate later.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I tried to grab the tail of the log:

[6.000] Unitsearch: u:/f/applications/fpc-331/units/atari/rtl/aes.pp
[6.000] Searching file u:/f/applications/fpc-331/units/atari/rtl/aes.pp... not found
[6.000] Unitsearch: u:/f/applications/fpc-331/units/atari/rtl/aes.pas
[6.000] Searching file u:/f/applications/fpc-331/units/atari/rtl/aes.pas... not found
[6.000] Unitsearch: aes.pp
[6.000] Searching file aes.pp... not found
[6.000] Unitsearch: aes.pas
[6.000] Searching file aes.pas... not found
[6.000] Unitsearch: ../../aes.pp
[6.000] Searching file ../../aes.pp... not found
[6.000] Unitsearch: ../../aes.pas
[6.000] Searching file ../../aes.pas... not found
[6.000] Unitsearch: u:/f/applications/fpc-331/aes.pp
[6.000] Searching file u:/f/applications/fpc-331/aes.pp... not found
[6.000] Unitsearch: u:/f/applications/fpc-331/aes.pas
[6.000] Searching file u:/f/applications/fpc-331/aes.pas... not found
[6.000] Unitsearch: u:/f/applications/fpc-331/units/atari/rtl/aes.pp
[6.000] Searching file u:/f/applications/fpc-331/units/atari/rtl/aes.pp... not found
[6.000] Unitsearch: u:/f/applications/fpc-331/units/atari/rtl/aes.pas
[6.000] Searching file u:/f/applications/fpc-331/units/atari/rtl/aes.pas... not found
[6.000] higem.pas(16,3) Fatal: Can't find unit aes used by higem
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Thu Jan 27, 2022 1:52 pm I also tried higem.pas from the examples but that failed, unable to find aes.ppu
I'll investigate later.
The aes unit is part of the tosunits package. It's part of the default build for Atari, obviously, so it's in that fpc archive I already linked, under units/atari/tosunits.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Thu Jan 27, 2022 2:58 pm I tried to grab the tail of the log:
Just this log isn't really helpful. For example your unit search paths are not visible in it. Full logs can be written to the disk: instead of -va, you might want to use use -veiw -vv. In this case, a more manageable set of information is displayed on the console window and the detailed log (-vv argument) is written into a file called "fpcdebug.txt" in the build directory. This file then can be shared easily or read after the build, when diagnosing issues. (Note the file is appended if it already exist, so you may want to delete it between runs.)
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
Post Reply

Return to “Coding”