C--

From OSDev.wiki
Revision as of 21:39, 4 August 2008 by osdev>Adek336
Jump to navigation Jump to search

C--

(This page is about Sphinx Full C--, not about C--, the portable assembly language

Sphinx Full C-- language is in between the C language and x86-assembly. It is a very neat computer language and the Shinx Full C-- compiler allows to produce (and mix) 16 bit and 32 bit code for real and protected modes.

Pros

  • good for writing real mode x86 operating systems;
  • good for writing TSR programs for DOS
  • good for writing x86-related parts of an operating system in a structured and easily readable and easier debuggable way related to structured languages like C and Pascal;
  • the code can be either low level (assembly-like), medium level (C like) or very easily mixed;
  • very good (because of the structured form) for writing small toy programs which are close to the hardware;
  • relatively easy to port from and to C-with-assembly.


Cons

  • not portable; it is very closely tied to the x86 assembly;
  • is developed by few developers, the community is small;
  • one compiler implementation availlable and only for one platform (DOS);
  • larger projects generally should be written in high-level languages, not low-level like Sphinx Full C--;
  • can be used for x86-related parts of an operating system, but doesn't give as much control as assembly and requires to have both C (or C++) and C-- compilers;

I am not sure on the output formats of the compiler but I fear it provides only flat-binary and dos exes. I don't know if it can output 64bit code.

Early versions of panaLiX used Sphinx Full C--.

Examples

?include "nosys.inc"
dword old0x21 = {};
interrupt int0x21()
{
    $PUSH DS
    $PUSH ES
    $PUSHA
    $PUSH FS
    DS = CS;
    FS = 0xb800;
    FSBYTE[1682] = '!';
    $POP FS
    $POPA
    $POP ES
    $POP DS
}