C--: Difference between revisions

312 bytes added ,  8 years ago
no edit summary
[unchecked revision][unchecked revision]
No edit summary
 
(11 intermediate revisions by 4 users not shown)
Line 1:
(This page is about Sphinx Full C--, not about [http://www.cminusminus.org/index.html C--], the portable assembly language].
==C--==
(This page is about Sphinx Full C--, not about [http://www.cminusminus.org/index.html C--, the portable assembly language]
 
Sphinx Full C-- language is in between the [[C|C language]] and x86-assembly. It is a very neat computer language and the ShinxSphinx Full C-- compiler allows to produce (and mix) 16 bit and 32 bit code for real and protected modes.
 
It was originally developed by Peter Cellik in Canada and then has been extended for several years by Michael Sheker in Russia.
===Pros===
 
==C--Pros==
* compiles very small executables;
* good for writing real mode x86 operating systems;
* good for writing TSR programs for DOS;
* supports many executable formats: COM, EXE, SYS (DOS drivers), ROM-BIOS, Windows PE-Coff, Windows DLL, 32bit DOS flat or DPMI, MenuetOS;
* 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;
* very good (because of the structured form) for writing small toy programs which are close to the hardware;
Line 14 ⟶ 17:
* 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; has less users than gcc so more may have more bugs;
* in order to be low-level, many limitations are in place: for example, array subscripts (like in x= myArr['''subscript''']) are limited to simple expressions (like myArr[10], myArr[ESI]; but myArr[myArr[1]] is not allowed);
* one compiler implementation availlable and only for one platform (DOS);
I don't know if* it can not output 64bit code.
* 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;
* C-with-asm pretty much does all the same.
 
Early versions of [[User:Adek336|panaLiX]] used Sphinx Full C--. The Panalix website is [http://panalix.sourceforge.net/ here] but there is no Sphinx C-- code currently available.
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.
 
==Examples==
Early versions of [[User:Adek336|panaLiX]] used Sphinx Full C--.
byte x = 0b01001;
word y;
dword z;
#define THIS_A_DEFINITION 123
 
===ExamplesTake over interrupt===
====Take over interrupt====
dword old0x21 = {};
interrupt int0x21()
Line 73 ⟶ 76:
ESBYTE[0x1b8005]= 127;
 
====read, write====
byte x;
word y;
dword z;
#define THIS_A_DEFINITION 123
 
====read, write====
void PRINTF()
{
Line 134 ⟶ 132:
}
 
====Disk IO====
byte readDisk(byte drive, head, sector, track, howmany; word segm, offs)
int err;
Line 241 ⟶ 239:
}
 
====Enable Protected Mode====
...
?code32 false
Line 283 ⟶ 281:
...
 
These snippets may seem a bit spaghetti code, but not because of some language defficiency but because I didn't look very far for them snippets.
 
===References===
* [http://c--sphinx.narod.ru/indexe.htm theThe compilers website]
* [http://www.dev0.de/cmm/indexe.htm Mirror of the compilers website]
* [https://github.com/jossk/c--sphinx Github site with all the files plus source for Sphinx C--]
 
[[Category:Languages]]
 
These snippets may seem a bit spaghetti code, but not because of some language defficiency but because I didn't look very far for them snippets.
 
===References===
* [http://c--sphinx.narod.ru/indexe.htm the compilers website]
Anonymous user