32-bit MSDOS (Announce)
> I decided to take a look at the assembler that
> was being generated by Free Pascal. I couldn't
> stop the assemble & link from happening, but
> I was able to keep the assembler which meant
> that I could simply redo the process.
Compile with -a -s. It will keep the assembler, and generate a script to assemble and link it (ppas.sh or ppas.bat)
> When I saw the generated assembler, ie
> fpc_write_text_shortstr etc, I had another
> thought. I don't know what the license is of
> the code that is currently being linked in to
> my world.exe,
LGPL+ static linking exception, roughly the same as gcc's libgcc. Nearly all linkable code has that license, only the compiler and the IDEs are GPL (again, much like gcc)
> I can produce my own executable
> consisting of nothing but public domain code,
> just like my C90-based executables.
C90 is a source standard. Calling binaries "C90" has no meaning.
> Unfortunately I don't know how to get my C
> code to selectively generate "pascal" calling
> convention, or whether Free Pascal's convention
> is even that. I tried __pascal and __Pascal.
> __stdcall does something different.
The calling convention is called "register", used by Delphi and Free Pascal, and is somewhat related to stdcall in philosophy. Probably the only C(actually C++) compilers that do it are Borland's BCB.
> Is this approach likely to work, or am I
> missing something?
Yes. Register calling convention support in the gcc compiler. Let the Pascal code call C.
> void fpc_initializeunits(void)
> {
> return;
> }
This is an identifier that calls what is equivalent to CTORs (table with initialization code of varying units). Without it, initialization code in units (including the system unit) wont work.
> int fpc_get_output(void)
> {
> return ((int)stdout);
> }
Ok. Is afaik a function for thread variable (TLS) reasons.
> void fpc_write_text_shortstr(int handle, char *str)
> {
> fputs(str, (FILE*)handle);
> return;
> }
This signature doesn't match. shortstrings are complicated beasts. Only replace the final call to the OS (in rtl/win/sysfile).
> void fpc_iocheck(void)
> {
> return;
> }
Would disables all I/O checking, and among others checking for the existence of a file relies on that, so wouldn't work.
If you want any measure of compatibility, replace _only_ the user32 DLL calls to msvcrt DLL calls, and let the msvcrt initializing be done using normal ways (dll_initialize), and don't go rearranging.
> void fpc_do_exit(int x)
> {
> exit(x);
> }
That's probably ok.
> Cannot export FPC_RESOURCESTRINGTABLES: symbol not found
> Cannot export FPC_RESSTRINITTABLES: symbol not found
> Cannot export FPC_THREADVARTABLES: symbol not found
> Cannot export FPC_WIDEINITTABLES: symbol not found
> Cannot export INITFINAL: symbol not found
> Cannot export PASCALMAIN: symbol not found
> worldpas.o(.text.n__main+0x5):worldpas.pas: undefined reference to
> `fpc_initializeunits'
> worldpas.o(.text.n__main+0xa):worldpas.pas: undefined reference to
> `fpc_get_output'
> worldpas.o(.text.n__main+0x1d):worldpas.pas: undefined reference to
> `fpc_write_text_shortstr'
> worldpas.o(.text.n__main+0x22):worldpas.pas: undefined reference to
> `fpc_iocheck'
> worldpas.o(.text.n__main+0x29):worldpas.pas: undefined reference to
> `fpc_writeln_end'
> worldpas.o(.text.n__main+0x2e):worldpas.pas: undefined reference to
> `fpc_iocheck'
> worldpas.o(.text.n__main+0x33):worldpas.pas: undefined reference to
> `fpc_do_exit'
> worldpas.o(.data.n_INITFINAL+0x8):worldpas.pas: undefined reference to
> `INIT$_$SYSTEM'
> worldpas.o(.data.n_INITFINAL+0x10):worldpas.pas: undefined reference to
> `INIT$_$FPINTRES'
> worldpas.o(.data.n_FPC_THREADVARTABLES+0x4):worldpas.pas: undefined
> reference to `THREADVARLIST_$SYSTEM$indirect'
> [worldpas.exe] Error 1
You didn't link FPC libraries or startup code. I wouldn't go this route, at least not for first steps, let Free Pascal generate the linking. You can tell it to link .o and .a's by doing {$L myobject.o} in the main program.
Use the earlier parameters to look at how it calls the linker, and then manipulate the source again till it works.
Complete thread:
- 32-bit MSDOS - kerravon, 26.06.2021, 15:52 (Announce)
- 32-bit MSDOS - tom, 27.06.2021, 13:23
- 32-bit MSDOS - kerravon, 27.06.2021, 13:46
- 32-bit MSDOS - tom, 27.06.2021, 14:14
- 32-bit MSDOS - kerravon, 27.06.2021, 14:58
- 32-bit MSDOS - Japheth, 27.06.2021, 16:09
- 32-bit MSDOS - kerravon, 27.06.2021, 17:46
- 32-bit MSDOS - Japheth, 28.06.2021, 05:54
- 32-bit MSDOS - kerravon, 28.06.2021, 07:15
- 32-bit MSDOS - RayeR, 28.06.2021, 13:43
- 32-bit MSDOS - kerravon, 28.06.2021, 15:04
- 32-bit MSDOS - tkchia, 28.06.2021, 19:00
- 32-bit MSDOS - kerravon, 29.06.2021, 00:34
- 32-bit MSDOS - kerravon, 29.06.2021, 01:52
- 32-bit MSDOS - marcov, 30.06.2021, 15:11
- 32-bit MSDOS - kerravon, 30.06.2021, 22:32
- 32-bit MSDOS - marcov, 30.06.2021, 22:42
- 32-bit MSDOS - kerravon, 30.06.2021, 22:57
- 32-bit MSDOS - marcov, 01.07.2021, 09:45
- 32-bit MSDOS - kerravon, 01.07.2021, 13:39
- 32-bit MSDOS - marcov, 01.07.2021, 15:54
- 32-bit MSDOS - kerravon, 02.07.2021, 00:59
- 32-bit MSDOS - kerravon, 02.07.2021, 13:31
- 32-bit MSDOS - marcov, 03.07.2021, 19:28
- 32-bit MSDOS - kerravon, 04.07.2021, 01:55
- 32-bit MSDOS - marcov, 04.07.2021, 22:29
- 32-bit MSDOS - kerravon, 05.07.2021, 00:31
- 32-bit MSDOS - marcov, 05.07.2021, 10:05
- 32-bit MSDOS - kerravon, 05.07.2021, 10:28
- 32-bit MSDOS - mceric, 05.07.2021, 12:40
- 32-bit MSDOS - kerravon, 05.07.2021, 14:00
- 32-bit MSDOS - mceric, 05.07.2021, 16:27
- 32-bit MSDOS - kerravon, 05.07.2021, 23:55
- 32-bit MSDOS - tom, 06.07.2021, 09:51
- 32-bit MSDOS - kerravon, 06.07.2021, 11:06
- 32-bit MSDOS - kerravon, 07.07.2021, 09:31
- 32-bit MSDOS - kerravon, 06.07.2021, 11:06
- 32-bit MSDOS - tom, 06.07.2021, 09:51
- 32-bit MSDOS - kerravon, 05.07.2021, 23:55
- 32-bit MSDOS - mceric, 05.07.2021, 16:27
- 32-bit MSDOS - kerravon, 05.07.2021, 14:00
- 32-bit MSDOS - mceric, 05.07.2021, 12:40
- 32-bit MSDOS - kerravon, 05.07.2021, 10:28
- 32-bit MSDOS - marcov, 05.07.2021, 10:05
- 32-bit MSDOS - kerravon, 05.07.2021, 00:31
- 32-bit MSDOS - marcov, 04.07.2021, 22:29
- 32-bit MSDOS - kerravon, 04.07.2021, 01:55
- 32-bit MSDOS - marcov, 03.07.2021, 19:28
- 32-bit MSDOS - marcov, 02.07.2021, 14:05
- 32-bit MSDOS - kerravon, 02.07.2021, 15:19
- 32-bit MSDOS - marcov, 02.07.2021, 16:02
- 32-bit MSDOS - mceric, 02.07.2021, 17:15
- 32-bit MSDOS - kerravon, 02.07.2021, 17:43
- 32-bit MSDOS - kerravon, 03.07.2021, 05:14
- 32-bit MSDOS - mceric, 03.07.2021, 13:03
- 32-bit MSDOS - kerravon, 03.07.2021, 13:16
- 32-bit MSDOS - marcov, 03.07.2021, 15:35
- 32-bit MSDOS - kerravon, 03.07.2021, 15:45
- 32-bit MSDOS - marcov, 03.07.2021, 19:06
- 32-bit MSDOS - kerravon, 04.07.2021, 02:00
- 32-bit MSDOS - kerravon, 04.07.2021, 02:50
- 32-bit MSDOS - marcov, 04.07.2021, 22:59
- 32-bit MSDOS - kerravon, 05.07.2021, 00:51
- 32-bit MSDOS - marcov, 05.07.2021, 10:00
- 32-bit MSDOS - kerravon, 05.07.2021, 10:23
- 32-bit MSDOS - marcov, 05.07.2021, 13:19
- 32-bit MSDOS - kerravon, 05.07.2021, 13:48
- 32-bit MSDOS - marcov, 05.07.2021, 13:19
- 32-bit MSDOS - kerravon, 05.07.2021, 10:23
- 32-bit MSDOS - marcov, 05.07.2021, 10:00
- 32-bit MSDOS - kerravon, 05.07.2021, 00:51
- 32-bit MSDOS - marcov, 04.07.2021, 22:59
- 32-bit MSDOS - kerravon, 04.07.2021, 03:10
- 32-bit MSDOS - kerravon, 04.07.2021, 03:15
- 32-bit MSDOS - kerravon, 04.07.2021, 05:24
- 32-bit MSDOS - kerravon, 04.07.2021, 05:32
- 32-bit MSDOS - marcov, 04.07.2021, 23:08
- 32-bit MSDOS - kerravon, 05.07.2021, 01:00
- 32-bit MSDOS - kerravon, 05.07.2021, 04:10
- 32-bit MSDOS - tkchia, 05.07.2021, 15:09
- 32-bit MSDOS - kerravon, 05.07.2021, 15:48
- 32-bit MSDOS - kerravon, 05.07.2021, 01:00
- 32-bit MSDOS - kerravon, 04.07.2021, 05:43
- 32-bit MSDOS - kerravon, 04.07.2021, 07:06
- 32-bit MSDOS - kerravon, 04.07.2021, 07:35
- 32-bit MSDOS - kerravon, 04.07.2021, 05:24
- 32-bit MSDOS - tkchia, 04.07.2021, 09:16
- 32-bit MSDOS - kerravon, 04.07.2021, 10:13
- 32-bit MSDOS - tkchia, 04.07.2021, 11:03
- 32-bit MSDOS - kerravon, 04.07.2021, 11:14
- 32-bit MSDOS - tkchia, 04.07.2021, 11:03
- 32-bit MSDOS - kerravon, 04.07.2021, 10:13
- 32-bit MSDOS - marcov, 04.07.2021, 22:57
- 32-bit MSDOS - kerravon, 05.07.2021, 00:48
- 32-bit MSDOS - kerravon, 04.07.2021, 03:15
- 32-bit MSDOS - marcov, 04.07.2021, 22:37
- 32-bit MSDOS - kerravon, 05.07.2021, 00:33
- 32-bit MSDOS - kerravon, 04.07.2021, 02:50
- 32-bit MSDOS - kerravon, 04.07.2021, 02:00
- 32-bit MSDOS - marcov, 03.07.2021, 19:06
- 32-bit MSDOS - kerravon, 03.07.2021, 15:45
- 32-bit MSDOS - marcov, 03.07.2021, 15:35
- 32-bit MSDOS - kerravon, 03.07.2021, 13:16
- 32-bit MSDOS - marcov, 03.07.2021, 14:30
- 32-bit MSDOS - marcov, 03.07.2021, 14:47
- 32-bit MSDOS - kerravon, 03.07.2021, 15:39
- 32-bit MSDOS - marcov, 03.07.2021, 16:12
- 32-bit MSDOS - kerravon, 03.07.2021, 16:23
- 32-bit MSDOS - marcov, 03.07.2021, 16:12
- 32-bit MSDOS - mceric, 03.07.2021, 13:03
- 32-bit MSDOS - kerravon, 03.07.2021, 05:14
- 32-bit MSDOS - kerravon, 02.07.2021, 17:43
- 32-bit MSDOS - kerravon, 02.07.2021, 17:40
- 32-bit MSDOS - marcov, 03.07.2021, 14:02
- 32-bit MSDOS - kerravon, 03.07.2021, 14:41
- 32-bit MSDOS - marcov, 03.07.2021, 15:54
- 32-bit MSDOS - kerravon, 03.07.2021, 16:16
- user32.dll - marcov, 03.07.2021, 19:48
- user32.dll - kerravon, 04.07.2021, 02:20
- user32.dll - marcov, 04.07.2021, 23:17
- user32.dll - kerravon, 05.07.2021, 01:07
- user32.dll - marcov, 04.07.2021, 23:17
- user32.dll - kerravon, 04.07.2021, 02:20
- user32.dll - marcov, 03.07.2021, 19:48
- 32-bit MSDOS - kerravon, 03.07.2021, 16:16
- 32-bit MSDOS - marcov, 03.07.2021, 15:54
- 32-bit MSDOS - kerravon, 03.07.2021, 14:41
- 32-bit MSDOS - marcov, 03.07.2021, 14:02
- 32-bit MSDOS - mceric, 02.07.2021, 17:15
- 32-bit MSDOS - marcov, 02.07.2021, 16:02
- 32-bit MSDOS - kerravon, 02.07.2021, 15:19
- 32-bit MSDOS - kerravon, 02.07.2021, 13:31
- 32-bit MSDOS - kerravon, 02.07.2021, 00:59
- 32-bit MSDOS - marcov, 01.07.2021, 15:54
- 32-bit MSDOS - kerravon, 01.07.2021, 13:39
- 32-bit MSDOS - marcov, 01.07.2021, 09:45
- 32-bit MSDOS - kerravon, 30.06.2021, 22:57
- 32-bit MSDOS - marcov, 30.06.2021, 22:42
- 32-bit MSDOS - kerravon, 30.06.2021, 22:32
- 32-bit MSDOS - tkchia, 30.06.2021, 19:04
- 32-bit MSDOS - kerravon, 30.06.2021, 22:42
- 32-bit MSDOS - marcov, 30.06.2021, 22:47
- 32-bit MSDOS - kerravon, 30.06.2021, 23:14
- 32-bit MSDOS - marcov, 30.06.2021, 22:47
- 32-bit MSDOS - kerravon, 30.06.2021, 22:42
- 32-bit MSDOS - marcov, 30.06.2021, 15:11
- 32-bit MSDOS - kerravon, 29.06.2021, 01:52
- 32-bit MSDOS - kerravon, 29.06.2021, 00:34
- 32-bit MSDOS - tom, 28.06.2021, 20:47
- 32-bit MSDOS - kerravon, 29.06.2021, 00:21
- 32-bit MSDOS - tkchia, 28.06.2021, 19:00
- 32-bit MSDOS - tkchia, 28.06.2021, 19:09
- 32-bit MSDOS - kerravon, 29.06.2021, 05:16
- 32-bit MSDOS - Japheth, 29.06.2021, 05:40
- 32-bit MSDOS - kerravon, 29.06.2021, 07:14
- 32-bit Public Domain DOS - tom, 30.06.2021, 22:19
- 32-bit MSDOS - Japheth, 29.06.2021, 05:40
- 32-bit MSDOS - kerravon, 28.06.2021, 15:04
- 32-bit MSDOS - RayeR, 28.06.2021, 13:43
- 32-bit MSDOS - kerravon, 28.06.2021, 07:15
- 32-bit MSDOS - Japheth, 28.06.2021, 05:54
- 32-bit MSDOS - kerravon, 27.06.2021, 18:00
- 32-bit MSDOS - kerravon, 27.06.2021, 18:31
- 32-bit MSDOS - kerravon, 27.06.2021, 18:47
- 32-bit MSDOS - Japheth, 27.06.2021, 20:40
- 32-bit MSDOS - kerravon, 27.06.2021, 20:57
- 32-bit MSDOS - kerravon, 27.06.2021, 22:12
- 32-bit MSDOS - kerravon, 27.06.2021, 20:57
- 32-bit MSDOS - Japheth, 27.06.2021, 20:40
- 32-bit MSDOS - bocke, 14.09.2021, 11:33
- 32-bit MSDOS - kerravon, 27.06.2021, 18:47
- 32-bit MSDOS - kerravon, 27.06.2021, 18:31
- 32-bit MSDOS - kerravon, 27.06.2021, 17:46
- 32-bit MSDOS - Japheth, 27.06.2021, 16:09
- 32-bit MSDOS - kerravon, 27.06.2021, 14:58
- YAOIS - Yet Another Irrelevant Operating System - tom, 27.06.2021, 20:03
- 32-bit MSDOS - kerravon, 27.06.2021, 20:18
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:23
- YAOIS - Yet Another Irrelevant Operating System - mceric, 27.06.2021, 20:28
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:47
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:51
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:53
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:54
- YAOIS - Yet Another Irrelevant Operating System - rr, 27.06.2021, 21:21
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:54
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:53
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:51
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 20:47
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 21:30
- YAOIS - Yet Another Irrelevant Operating System - kerravon, 27.06.2021, 21:59
- a.out support in dos - DosWorld, 04.07.2021, 11:22
- a.out support in dos - kerravon, 04.07.2021, 12:01
- a.out support in dos - marcov, 04.07.2021, 23:22
- 32-bit MSDOS - DosWorld, 24.09.2021, 20:54
- 32-bit MSDOS - tom, 27.06.2021, 14:14
- 32-bit MSDOS - kerravon, 27.06.2021, 13:46
- 32-bit MSDOS - RayeR, 28.06.2021, 03:59
- 32-bit MSDOS - kerravon, 28.06.2021, 07:13
- 32-bit MSDOS - Zyzzle, 28.06.2021, 06:22
- 32-bit MSDOS - kerravon, 28.06.2021, 07:30
- 32-bit MSDOS - marcov, 30.06.2021, 22:49
- 32-bit MSDOS - kerravon, 30.06.2021, 23:08
- 32-bit MSDOS - mceric, 01.07.2021, 01:52
- 32-bit MSDOS - kerravon, 01.07.2021, 06:37
- 32-bit MSDOS - tkchia, 03.07.2021, 22:13
- 32-bit MSDOS - kerravon, 04.07.2021, 01:50
- 32-bit MSDOS - tkchia, 04.07.2021, 09:08
- 32-bit MSDOS - kerravon, 04.07.2021, 10:05
- 32-bit MSDOS - tkchia, 04.07.2021, 10:53
- 32-bit MSDOS - kerravon, 04.07.2021, 10:05
- 32-bit MSDOS - tkchia, 04.07.2021, 09:08
- 32-bit MSDOS - kerravon, 04.07.2021, 01:50
- 32-bit MSDOS - Brian_extended, 24.07.2021, 02:10
- 32-bit MSDOS - kerravon, 06.08.2021, 13:56
- 32-bit Public Domain OS - tom, 06.08.2021, 15:21
- 32-bit Public Domain OS - kerravon, 06.08.2021, 15:57
- 32-bit Public Domain OS - tom, 06.08.2021, 15:21
- 32-bit MSDOS - kerravon, 07.08.2021, 05:41
- 32-bit MSDOS - kerravon, 06.08.2021, 13:56
- 32-bit MSDOS - mceric, 01.07.2021, 01:52
- 32-bit MSDOS - kerravon, 30.06.2021, 23:08
- 32-bit MSDOS - RayeR, 03.08.2021, 06:59
- 32-bit MSDOS - kerravon, 06.08.2021, 13:50
- 32-bit MSDOS - RayeR, 06.08.2021, 15:09
- 32-bit MSDOS - kerravon, 06.08.2021, 16:07
- 32-bit MSDOS - RayeR, 20.08.2021, 18:59
- 32-bit MSDOS - kerravon, 27.09.2021, 04:28
- 32-bit MSDOS - mceric, 28.09.2021, 01:04
- 32-bit MSDOS - kerravon, 14.10.2021, 04:37
- 32-bit MSDOS - mceric, 28.09.2021, 01:04
- 32-bit MSDOS - kerravon, 27.09.2021, 04:28
- 32-bit MSDOS - RayeR, 20.08.2021, 18:59
- 32-bit MSDOS - kerravon, 06.08.2021, 16:07
- 32-bit MSDOS - RayeR, 06.08.2021, 15:09
- 32-bit MSDOS - kerravon, 06.08.2021, 13:50
- 32-bit MSDOS - dggionco, 09.08.2021, 14:43
- 32-bit MSDOS - kerravon, 09.08.2021, 15:39
- 32-bit MSDOS - dggionco, 09.08.2021, 20:00
- 32-bit MSDOS - kerravon, 09.08.2021, 21:25
- 32-bit MSDOS - dggionco, 10.08.2021, 14:58
- 32-bit MSDOS - kerravon, 10.08.2021, 17:06
- 32-bit MSDOS - dggionco, 10.08.2021, 18:06
- 32-bit MSDOS - kerravon, 10.08.2021, 17:06
- 32-bit MSDOS - dggionco, 10.08.2021, 14:58
- 32-bit MSDOS - kerravon, 09.08.2021, 21:25
- 32-bit MSDOS - dggionco, 09.08.2021, 20:09
- 32-bit MSDOS - dggionco, 09.08.2021, 20:00
- 32-bit MSDOS - kerravon, 09.08.2021, 15:39
- 32-bit MSDOS - tom, 27.06.2021, 13:23