Atari mini-clone

GFA, ASM, STOS, ...

Moderators: Zorro 2, Moderator Team

kerravon
Atari freak
Atari freak
Posts: 54
Joined: Fri Mar 05, 2021 9:26 am

Re: Atari mini-clone

Post by kerravon »

kerravon wrote: Tue Jun 18, 2024 4:21 pm
SteveBagley wrote: Mon Jun 17, 2024 5:07 pm The entry point is simply always the first instruction after the header. ST software is written or linked knowing this is the case (I.e. the c start-up object file would be linked first).

If you want to start somewhere else, stick a jmp instruction there to jump to where you need to be
Ok, thanks.

I have now constructed a testcase:

https://sourceforge.net/p/pdos/gitcode/ ... aritst.asm

And I am attaching the executable that was produced by the most recent pdld (hours old).

Hopefully it is valid and this is what I will try to run first when I get my mini clone started.
temp.zip
Actually I can't use that exact executable - I don't have the trap override facility in it. So it will need to wait until I have modified my C library.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3419
Joined: Sun Aug 03, 2014 5:54 pm

Re: Atari mini-clone

Post by ThorstenOtto »

kerravon wrote: Mon Jun 17, 2024 11:43 am I also do not understand ph_branch which should be 0x601a but how can entry point be specified then?
The ph_branch is part of the file header. It just happens to be a short branch instruction which would skip the file header, but is not really executed.

When TOS loads a programs, it basically loads text & data from the executable (without the file header), then jumps to the first instruction of the text segment.
The gnu-c toolchain for atari solves the problem of a custom entrypoint, by using another header after the GEMDOS fileheader. The first instructions of the text segment then load the address of the entrypoint from the known location of that extended header, and jump to it.
kerravon
Atari freak
Atari freak
Posts: 54
Joined: Fri Mar 05, 2021 9:26 am

Re: Atari mini-clone

Post by kerravon »

kerravon wrote: Tue May 28, 2024 6:00 am Ok, I'm back, after a flurry of activity on MSDOS and mainframe - mainly the mainframe. A lot of direction and work lined up.
The first results of the technique invented here are now available (mainframe had priority over Atari).

There are 3 mainframe OSes from IBM still around today (quibbling aside) - MVS, CMS and VSE.

For various reasons I started on the smallest - VSE.

The startup code needs to look like this:

https://sourceforge.net/p/pdos/gitcode/ ... pa.asm#l24

__pgparm: .long 0 # This will be zapped by z/PDOS-generic if running under it

so that my clone can zap the executable at load time.

On real VSE it will issue an SVC (equivalent of a trap), but on z/PDOS-generic it will instead do a call to a callback that takes the same parameters as the generalized SVC function. Here's that code:

https://sourceforge.net/p/pdos/gitcode/ ... upc.c#l119

int __svc(int svcnum, void *regsin, void *regsout)
{
if (__pgparm == 0)
{
return (__svcreal(svcnum, regsin, regsout));
}
else
{
return (__pgparm->Xservice(svcnum, regsin, regsout));
}
}

There was a lot of other infrastructure I needed to get working before I could stand this up.


In short - thanks guys for creating the idea, and I hope to get a suitable technique - not necessarily this one - working on the Atari eventually too.
kerravon
Atari freak
Atari freak
Posts: 54
Joined: Fri Mar 05, 2021 9:26 am

Re: Atari mini-clone

Post by kerravon »

kerravon wrote: Tue May 28, 2024 6:00 am Ok, I'm back, after a flurry of activity on MSDOS and mainframe - mainly the mainframe. A lot of direction and work lined up.
It is MSDOS that happened first. In an unexpected direction.

The end result is here:

https://www.bttr-software.de/forum/boar ... p?id=22441

Thanks guys for the idea on how to bypass INT 21H.

I'll get back to the Atari in due course, especially with the technique I ended up using (checking es != ds). I need to check again, but I expect something similar can be done with the Atari.

BFN. Paul.
kerravon
Atari freak
Atari freak
Posts: 54
Joined: Fri Mar 05, 2021 9:26 am

Re: Atari mini-clone

Post by kerravon »

ThorstenOtto wrote: Mon May 20, 2024 7:45 am I would think you need something like libcmini (https://github.com/freemint/libcmini), and then replace the startup code and OS-calls by something else.
So what sort of Atari executables exist, what registers do they expect to be set on entry
Do you mean the startup code? Normally, TOS places a pointer to the BASEPAGE at 4(sp), and zero in a0 (if a0 is non-zero, that is instead the pointer to the basepage, but that is only used for accessories running under gem). But if i understand correctly, you have to do the loading yourself, so basically its up to you what you provide there.
So now that I have seen more ways of doing overrides, what I would propose is that my Atari .PRG programs check to see if a0 is x'ffffffff', and if so, know that is invalid, and then check a1 for a "PDOS-generic parameter", which is under my control (I would provide a way for others to reuse the same extension though), and I can put a pointer to a basepage in there as well.

My clone would set this extra a1 register and demand that all applications use the callback function I provide in there to do a trap68000().

And obviously to start with, the only programs that are even aware of the "new rules" are my own PDPCLIB-based ones, so they are the only thing that will work under my mini-clone.

But all my executables will work under both my mini-clone plus real TOS.

ie exactly what I am looking for.

And a quite simple solution in the end.

Oh - another thing that happened since I first posted was that I managed to find some public domain single precision floating point code, and add some wrappers to convert double precision to single precision, and was able to get gccami to generate soft floating point, plus write the 68000 assembly necessary to do a divide, so that I could start generating 68000 code instead of 68020 code.

So I believe I am in a position to do the Atari work now.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3419
Joined: Sun Aug 03, 2014 5:54 pm

Re: Atari mini-clone

Post by ThorstenOtto »

kerravon wrote: Tue May 13, 2025 1:50 pm I managed to find some public domain single precision floating point code, and add some wrappers to convert double precision to single precision, and was able to get gccami to generate soft floating point, plus write the 68000 assembly necessary to do a divide, so that I could start generating 68000 code instead of 68020 code.
The cpm archives (which is what the alcyon compiler was based on) also have some single-precision floating point math library. They all mention "copyright 1980 by motorola inc", but since they were released freely by DRI, i think they could also be used. But dunno how good they are, TOS did not need them.
kerravon
Atari freak
Atari freak
Posts: 54
Joined: Fri Mar 05, 2021 9:26 am

Re: Atari mini-clone

Post by kerravon »

ThorstenOtto wrote: Tue May 13, 2025 5:23 pm
kerravon wrote: Tue May 13, 2025 1:50 pm I managed to find some public domain single precision floating point code, and add some wrappers to convert double precision to single precision, and was able to get gccami to generate soft floating point, plus write the 68000 assembly necessary to do a divide, so that I could start generating 68000 code instead of 68020 code.
The cpm archives (which is what the alcyon compiler was based on) also have some single-precision floating point math library. They all mention "copyright 1980 by motorola inc", but since they were released freely by DRI, i think they could also be used. But dunno how good they are, TOS did not need them.
CP/M is still copyrighted. I don't even know what "non-exclusive" means as far as permissions are concerned, and attempted to contact Bryan Sparks in 2023 but didn't get a reply.

Roll on PDOS ...

Return to “Coding”