Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

32-bit MSDOS (Announce)

posted by kerravon E-mail, Ligao, Free World North, 03.07.2021, 05:14

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.

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, but since I have a presumably
entirely different approach, that isn't
relevant - I can produce my own executable
consisting of nothing but public domain code,
just like my C90-based executables.

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.

Is this approach likely to work, or am I
missing something?

Thanks. Paul.



C:\devel\pascal>type pascal.c
/* public domain by Paul Edwards */

#include <stdio.h>
#include <stdlib.h>

void fpc_initializeunits(void)
{
return;
}

int fpc_get_output(void)
{
return ((int)stdout);
}

void fpc_write_text_shortstr(int handle, char *str)
{
fputs(str, (FILE*)handle);
return;
}

void fpc_iocheck(void)
{
return;
}

void fpc_writeln_end(void)
{
printf("\n");
}

void fpc_do_exit(int x)
{
exit(x);
}



C:\devel\pascal>type worldpas.pas
program world;

begin
writeln('Hello, World')
end.



C:\devel\pascal>type makefile.w32
# Produce Windows executables
# links with PDPCLIB created by makefile.msv

CC=gccwin
CFLAGS=-O2
LD=ldwin
LDFLAGS=
AS=aswin
AR=arwin
COPTS=-S $(CFLAGS) -fno-common -ansi -I. -I../pdos/pdpclib -D__WIN32__

all: clean worldpas.exe

worldpas.exe: worldpas.o pascal.o
$(LD) $(LDFLAGS) -s -o worldpas.exe ../pdos/pdpclib/w32start.o worldpas.o pascal.o ../pdos/pdpclib/msvcrt.a


# This produces an executable and I don't know how to stop it
.pas.o:
fpc -a $<
$(AS) -o $@ $*.s

.c.o:
$(CC) $(COPTS) -o $*.s $<
$(AS) -o $@ $*.s
rm -f $*.s

clean:
rm -f *.o worldpas.exe




C:\devel\pascal>pdmake -f makefile.w32
rm -f *.o worldpas.exe
fpc -a worldpas.pas
Free Pascal Compiler version 3.2.2 [2021/05/15] for i386
Copyright (c) 1993-2021 by Florian Klaempfl and others
Note: Switching assembler to default source writing assembler
Target OS: Win32 for i386
Compiling worldpas.pas
Assembling world
Linking worldpas.exe
5 lines compiled, 0.1 sec, 28224 bytes code, 1268 bytes data
1 note(s) issued
aswin -o worldpas.o worldpas.s
gccwin -S -O2 -fno-common -ansi -I. -I../pdos/pdpclib -D__WIN32__ -o pascal.s pascal.c
aswin -o pascal.o pascal.s
rm -f pascal.s
ldwin -s -o worldpas.exe ../pdos/pdpclib/w32start.o worldpas.o pascal.o ../pdos/pdpclib/msvcrt.a
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

 

Complete thread:

Back to the forum
Board view  Mix view
22632 Postings in 2109 Threads, 402 registered users, 389 users online (1 registered, 388 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum