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, 05.07.2021, 13:48

> Change result:=32; to bla:=32;

Thanks. Works fine. I see that it does a
second compile of unit1.pas, but I couldn't
care less about that. No technical barrier
encountered so far.

BFN. Paul.



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

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

void fpc_initializeunits(void)
{
return;
}

int fpc_get_output(void)
{
static FILE *x = NULL;

if (x == NULL)
{
x = stdout;
}

return ((int)&x);
}

void fpc_write_text_shortstr(int handle, unsigned char *str, int unknown)
{
fwrite(str + 1, str[0], 1, *(FILE **)handle);
return;
}

void fpc_write_text_sint(int handle, int val, int unknown)
{
fprintf(*(FILE **)handle, "%d", val);
return;
}

void fpc_iocheck(void)
{
return;
}

void fpc_writeln_end(int handle)
{
fprintf(*(FILE **)handle, "\n");
return;
}

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

void fpc_assign_short_string(char *a, char *b)
{
a += sizeof(FILE *);
strcpy(a, b);
return;
}

void fpc_rewrite(void *a)
{
char *name = (char *)a + sizeof(FILE *) + 1;
FILE *fq;

fq = fopen(name, "w");
*(FILE **)a = fq;
return;
}

C:\devel\pascal2>




C:\devel\pascal2>type pascala.asm
# public domain by Paul Edwards

.section .text
.balign 16,0x90

.globl fpc_initializeunits
fpc_initializeunits:
call _fpc_initializeunits
ret

.globl fpc_get_output
fpc_get_output:
call _fpc_get_output
ret


# edx has file handle
# ecx has string to print, first character has length
# eax has a 0, don't know what that is

.globl fpc_write_text_shortstr
fpc_write_text_shortstr:
push %eax
push %ecx
push %edx
call _fpc_write_text_shortstr

add $12, %esp
ret

.globl fpc_write_text_sint
fpc_write_text_sint:
push %eax
push %ecx
push %edx
call _fpc_write_text_sint

add $12, %esp
ret

.globl fpc_iocheck
fpc_iocheck:
call _fpc_iocheck
ret

.globl fpc_writeln_end
fpc_writeln_end:
push %eax
call _fpc_writeln_end
add $4, %esp
ret

.globl fpc_do_exit
fpc_do_exit:
call _fpc_do_exit
ret

# %eax is destination, %edx is source
.globl SYSTEM_$$_ASSIGN$TEXT$SHORTSTRING
SYSTEM_$$_ASSIGN$TEXT$SHORTSTRING:
push %edx
push %eax
call _fpc_assign_short_string
add $8, %esp
ret

.globl SYSTEM_$$_REWRITE$TEXT
SYSTEM_$$_REWRITE$TEXT:
push %eax
call _fpc_rewrite
add $4, %esp
ret

.section .data

.globl INIT$_$SYSTEM
INIT$_$SYSTEM:

.globl INIT$_$FPINTRES
INIT$_$FPINTRES:

.globl THREADVARLIST_$SYSTEM$indirect
THREADVARLIST_$SYSTEM$indirect:

C:\devel\pascal2>




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

CC=gccwin
CFLAGS=-O2
# ldwin gives unresolved externals that require --noinhibit-exec
# to work around if "ld" can't be used. Given that we're currently
# dependent on fpc itself, adding ld to the dependency list is
# not onerous.
LD=ld
LDFLAGS=
AS=aswin
AR=arwin
COPTS=-S $(CFLAGS) -fno-common -ansi -I. -I../pdos/pdpclib -D__WIN32__

all: clean prg.exe

prg.exe: prg.o unit1.o pascalc.o pascala.o
$(LD) $(LDFLAGS) -s -o prg.exe ../pdos/pdpclib/w32start.o prg.o unit1.o pascalc.o pascala.o ../pdos/pdpclib/msvcrt.a


# Without "-s", this produces an executable (but can be ignored)
# With "-s" this produces crap (which can be deleted)
# I choose to delete crap
.pas.o:
fpc -a -s $<
rm -f link*.res
rm -f ppas.bat
rm -f *.ppu
$(AS) -o $@ $*.s
rm -f $*.s

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

.asm.o:
$(AS) -o $@ $<

clean:
rm -f *.o prg.exe

C:\devel\pascal2>

 

Complete thread:

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