Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to index page
Thread view  Board view
georgpotthast(R)

Homepage

Germany,
19.10.2015, 19:21
 

Sphinx C-- source code available (Announce)

Some of you may recall Sphinx C--, a C compiler that allows to generate very small executables. Supported are the following executables: COM, EXE, SYS (DOS drivers), ROM-BIOS, Windows PE-Coff, Windows DLL, 32bit DOS flat or DPMI, MenuetOS.

At long last the source code has been released by Michael Sheker and is available here:
https://github.com/jossk/c--sphinx This is the site of Kirill Joss in Kiev.
There are also all binary, documentation and example files available for download.

The original Sphinx C-- website is broken but you can use this mirror site to read about C-- or download the files except the source code: http://www.dev0.de/cmm/indexe.htm

Georg

Guti(R)

Homepage

20.10.2015, 17:27

@ georgpotthast
 

Sphinx C-- source code available

Very strange it decided to upload RAR an ZIP files to Github, instead of raw uncompressed sources and/or binaries.

Not clear if the intention is to preserve it, or try to give it a new maintenance and improvements.

Personally loved Sphinx, not suitable for real applications. In fact, it was coded in C++ not in Spinx itself. Any way, was funny to code with it, quite likely an enhanced macro assembler with high level structures.

> Some of you may recall Sphinx C--, a C compiler that allows to generate
> very small executables. Supported are the following executables: COM, EXE,
> SYS (DOS drivers), ROM-BIOS, Windows PE-Coff, Windows DLL, 32bit DOS flat
> or DPMI, MenuetOS.
>
> At long last the source code has been released by Michael Sheker and is
> available here:
> https://github.com/jossk/c--sphinx
> This is the site of Kirill Joss in Kiev.
> There are also all binary, documentation and example files available for
> download.
>
> The original Sphinx C-- website is broken but you can use this mirror site
> to read about C-- or download the files except the source code:
> http://www.dev0.de/cmm/indexe.htm
>
> Georg

---
Visit my personal blog at http://www.javiergutierrezchamorro.com

georgpotthast(R)

Homepage

Germany,
20.10.2015, 20:58

@ Guti
 

Sphinx C-- source code available

> Very strange it decided to upload RAR an ZIP files to Github, instead of
> raw uncompressed sources and/or binaries.
>

I also mentioned that to Kirill and he at least has the intention to extend the Github site to uncompressed sources.

> Not clear if the intention is to preserve it, or try to give it a new
> maintenance and improvements.
>

Currently the files apparently are uploaded as they were released by Michael Sheker with the main intention to preserve them and make them available this way too.

RayeR(R)

Homepage

CZ,
20.10.2015, 19:17

@ georgpotthast
 

Sphinx C-- source code available

> Some of you may recall Sphinx C--, a C compiler that allows to generate
> very small executables. Supported are the following executables: COM, EXE,
> SYS (DOS drivers), ROM-BIOS, Windows PE-Coff, Windows DLL, 32bit DOS flat
> or DPMI, MenuetOS.

Hm, ROM-BIOS target, interesting :) Does it produce a complete ISA/PCI ROM module with necessary headers or just a code that can run from ROM? Coreboot project used its ROMC that enable you to write a bootblock in C because it doesn't require any RAM/stack (it's necessary before MCH is initialized). All vars are allocated in registers. So this makes of course several limitations but avoid asm...

---
DOS gives me freedom to unlimited HW access.

georgpotthast(R)

Homepage

Germany,
20.10.2015, 21:03

@ RayeR
 

Sphinx C-- source code available

I have not yet wrote code for ROM-BIOS but here is the section from the manual which may give some clues:

12.7 Compiling ROM-BIOS extender code
--------------------------------------

ROM-BIOS extenders (BIOS video controllers, network cards, etc.) have a
specific structure and requirements. C-- now makes it easier to create
ROM-BIOS code. Start the compiler with the command-line switch /rom and it
will create a ROM-BIOS signature, fill the remaining free space to the
specified ROM size with filler bytes, and count and correct the ROM
checksum.

There are several specific directives for this mode of compilation:

1. ?sizerom value - this directive tells the compiler the size of the
ROM in bytes. If not specified, the compiler will choose the smallest
proper ROM size from: 1024, 2048, 4096, 8192, 16384, 32762 or 65536. Space
not occupied by code or data will be filled up to the ROM size with a fill
byte specified by the directive ?aligner, which is by default 0. For type
27xxx ROM this byte should be 0xFF. The last ROM byte is corrected by the
compiler so that the checksum will be equal to zero.

2. ?movedatarom TRUE/FALSE - this directive tells the compiler whether
it must copy data from ROM to RAM. By default it is FALSE. If TRUE, the
compiler inserts into the initialization area code which copies data from
ROM to RAM. Register DS is set to a RAM segment. The stack is also set to
this segment. Thus 'main' obtains control over registers AX=ES=DS=SS=RAM
segment with data transferred to it. If this directive is set FALSE, DS is
still set to the address of the RAM segment, since your code will use this
segment for noninitialized global variables. Initialized variables will
remain in the ROM and all access to them will be via CS. The stack will not
be touched either (it will remain as it was set by the main BIOS).

3. ?dataseg value - this directive tells the compiler the segment
address of the RAM which may be used by the code, by default 0x70. To see
what this address is, you can read it from your code at offset 4. For
example: DS = CSWORD[4]

Some remarks:

1. At the time of initializing the ROM-BIOS, DOS has not yet been
loaded, and thus functions which use DOS calls will not work.

2. ABORT() or (EXIT() and the like cannot be used to terminate a
program. Operation of a ROM-BIOS extender can be terminated only by exiting
main().

3. If the directive ?movedatarom is set to FALSE, be careful when
working with initialized variables. In this mode they are only accessible
for reading and they are addressed via register CS.

RayeR(R)

Homepage

CZ,
20.10.2015, 22:26

@ georgpotthast
 

Sphinx C-- source code available

So yes, it produces the complete ROM image that is ready to burn to the chip or loaded in BOCHS emulator. There's no detailed info if it also includes PnP and PCI ROM header - as some modern BIOSes refuse to execute plain old-style ROM images (with 55 AA size header only). This can be checked easily viewing the compiled image. If PCI PnP header is missing it would need the ability of compiler to place some constant data structure at specific offset in the image and properly add jump to code beginning behind the header. I could try it...when will be time...

---
DOS gives me freedom to unlimited HW access.

georgpotthast(R)

Homepage

Germany,
21.10.2015, 17:55

@ RayeR
 

Sphinx C-- source code available

I assume it will not support PnP BIOS. But this is the code that makes the ROM-BIOS image structure. Maybe that gives you an answer:

#ifdef __ROM__
#ifdef __SMALL__
dword bakstack=0;
#endif
//static byte sign[2]={0x55,0xAA};
//static byte sizerom=__ROMSIZE/512;
__startupproc()
inline
{
$DW 0xAA55
$DB __ROMSIZE/512
#ifdef __SMALL__
ES=__DATASEG;
DI=0;
$cld
$cli
$db 0xB8 //mov ax,stackstart
__stackval:
__stackstart:
$dw 0
AX><SP;
$stosw
AX=SS;
$stosw
AX=ES;
SS=AX;
$sti
$db 0xBE //mov si,startdata
__startdata:
$dw 0
DS=CS;
$db 0xBE //mov cx,sizedata/2
__sizedata:
$dw 0
$rep $movsw
#else
AX=__DATASEG;
#endif
DS=AX;
main();
#ifdef __SMALL__
$cli
SP=DSWORD[0];
SS=DSWORD[2];
$sti
#endif
$retf
#undef __ROMSIZE
#undef __DATASEG
}
#endif

RayeR(R)

Homepage

CZ,
21.10.2015, 18:30

@ georgpotthast
 

Sphinx C-- source code available

Hm yes,
seems that
__startupproc() starts at address 0 of the image and then you can fill constant by $DB, $DW like in asm...

---
DOS gives me freedom to unlimited HW access.

Back to index page
Thread view  Board view
15192 Postings in 1365 Threads, 250 registered users, 13 users online (1 registered, 12 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum