13 March 2021, 13:55 | #161 |
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
|
13 March 2021, 14:04 | #162 | |||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
First and foremost, I don't understand *why* you want to do that. MS-DOS is a mostly irrelevant "operating" system today, as is AmigaOs.
Quote:
This is typically the startup code from the compiler (c.o for SAS/C). Quote:
Quote:
Once again, in case you misunderstand: A6 already has a value. It is not SysBase, and it is not the base of any library you prepare. Of course you can deviate from the AmigaOs API, but then you would not be able to run AmigaOs programs. AmigaOs programs do not expect SysBase in a6, though some are expecting the BCPL "return from function" function in a6. |
|||
13 March 2021, 15:07 | #163 | ||||||||||||||||||
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||||||||||||||
13 March 2021, 15:23 | #164 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,764
|
In AmigaOS a6 is used as the library base for library function calls, including those of the OS. When calling an OS function, d0, d1, a0 and a1 are assumed to be scratch registers, so don't depend on their value after the call.
That's all there's to it. Basically you can do what you want. Except when calling a library function (including the OS) you can use any registers for whatever you want. |
13 March 2021, 15:27 | #165 | |
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Quote:
pos.o will contain functions like this: int PosOpenFile(const char *name, int mode, int *handle) { return (SysBase->PosOpenFile(name, mode, handle)); } Note that I'm going to do it that way to prove that it can be done, but later on I will change that to: PosBase->PosOpenFile(name, mode, handle)); And yes, those MSDOS-API-using AmigaOS executables will crash and burn when run under AmigaOS, because there is no such function PosOpenFile there. However, when that exact same AmigaOS executable is run under AmigaPDOS, it will work just fine. For reference, the MSDOS and PDOS/386 version of PosOpenFile() are defined completely different from the AmigaPDOS version, but users of the program will not notice one iota of difference, and all versions (AmigaPDOS, PDOS/386, PDOS/86 and future PDOS/3X0-generic) will run at native speed after recompilation. BFN. Paul. int PosOpenFile(const char *name, int mode, int *handle) { union REGS regsin; union REGS regsout; struct SREGS sregs; regsin.h.ah = 0x3d; regsin.h.al = (unsigned char)mode; #ifdef __32BIT__ regsin.d.edx = (unsigned int)name; #else sregs.ds = FP_SEG(name); regsin.x.dx = FP_OFF(name); #endif int86x(0x21, ®sin, ®sout, &sregs); #ifdef __32BIT__ if (regsout.x.cflag) return (regsout.d.eax); *handle = regsout.d.eax; #else if (regsout.x.cflag) return (regsout.x.ax); *handle = regsout.x.ax; #endif return (0); } |
|
13 March 2021, 15:33 | #166 | ||
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Quote:
Quote:
The only ones I know of are d0 and a0. Does anyone at all, ever, in history, ever expect any other registers to be set on entry to their executable? If so, which ones, so that I can avoid them to avoid confusion. And if d0 and a0 are in fact the only ones actually in use, and all the other registers are free for me to use for my own (AmigaPDOS) purpose, then is there some register you would recommend, to "look the nicest" for my "alternate SysBase"? |
||
13 March 2021, 15:48 | #167 | ||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
Quote:
Note that for passing command line arguments, providing them in d0/a0 is not sufficient, any many (if not most) programs in C: do not bother with these registers and they receive command line arguments by other means. D1-D4 are the first four arguments of a BPCL function call, and D5-D7 are work registers. Thus, as far as passing "secret startup code" to functions, everything from D5 up should be ok. Note, however, that the protocol for starting an AmigaOs binary is not as simple as loading the command line to a0/d0. The right protocol is through dos.library/RunCommand(), and this function does not allow you to specify any register values to be passed to the called program. It takes the argument line provided, and passes that in an "appropriate" way that is irrelevant. Thus, to repeat that again, you don't start AmigaOs binaries yourself. You let the dos.library do that, and dos does not provide a mechanism to populate any registers in a non-standard way. Quote:
Also note that "SysBase" is a reserved name once you want to use any AmigaOs function, it is supposed to point to ExecBase, and only that. Once a program wants to call any function in exec.library, it would require this symbol, and exec requires a6 to be loaded with SysBase, the real one, and nothing else. So you shouldn't use that symbol, it is asking for trouble. PDosBase would be a better name anyhow. |
||
13 March 2021, 15:56 | #168 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,764
|
Quote:
Don't pick what looks best, pick what works best, and that depends on how your code works. |
|
13 March 2021, 16:01 | #169 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
|
13 March 2021, 16:36 | #170 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,764
|
|
13 March 2021, 16:42 | #171 | |||||||||
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
|||||||||
13 March 2021, 17:12 | #172 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
Yes, and if you load a binary that is compiled for AmigaOs, and do not start it through RunCommand() (or the workbench interface, for that matter) chances are that it wouldn't work. As long as you start binaries designed for your API, everything might be fine. But then again, why encode them in the Tripos HUNK format (which is rather limited) and not use something saner, such as Elf?
|
13 March 2021, 17:17 | #173 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
Quote:
I as a programmer? Well, nowadays, I wouldn't bother about all that stuff anymore. I would locate SysBase, then open dos.library, then call ReadArgs(). That doesn't require any arguments in any registers whatsoever. These registers are all for the legacy Tripos nonsense, and they are used by the BCPL startup code of BCPL binaries that are still supposed to work. |
|
13 March 2021, 17:47 | #174 | |||
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Quote:
Quote:
Quote:
|
|||
13 March 2021, 17:50 | #175 | |
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Quote:
|
|
13 March 2021, 17:55 | #176 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
Quote:
*Sigh* Lauch the binary through RunCommand(). |
|
13 March 2021, 17:59 | #177 | ||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,233
|
Quote:
Quote:
You are looking from the completely wrong side at the interface you are trying to invent. Passing magic values through magic registers is not going to help you if you want some sort of compatibility with AmigaOs. You have your own function API. Well, fine enough. This can be either statically linked to the binary as form of a function library, or can be part of an external dynamic library programs open. This happened for the posix interface layer, for example, which is implemented through a library named iexemul. |
||
13 March 2021, 18:04 | #178 |
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
No, I'm talking about the receiving end. An AmigaOS hunk being run under Tripos and receiving all those registers. Is it possible to detect that this is a Tripos environment and all those registers are available and should be used for something?
|
13 March 2021, 18:09 | #179 | ||||
Registered User
Join Date: Mar 2021
Location: Sydney, Australia
Posts: 186
|
Again, you wouldn't believe how many times I have heard that.
Quote:
Quote:
Quote:
Quote:
|
||||
13 March 2021, 18:12 | #180 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,764
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|