Page 1 of 1
Small C Compiler for KolibriOS [v 0.5.4]
Posted: Fri Feb 08, 2008 3:43 am
by jacekm
SCC 0.5.4 [bin + source]:
http://jacekm.net/kolibrios/SCC054.zip
SCC 0.5.3 [source]:
http://jacekm.net/kolibrios/SCC053.zip
SCC 0.5.2 [bin + source]
http://jacekm.net/kolibrios/SCC052.zip
I've ported CCOMP to KolibriOS.
It's very buggy at the moment so use it at your risk.
Code: Select all
KNOWN BUGS:
* only directiory /rd/1/ works
HISTORY:
* 0.5.4:
- output file extension is fixed
* 0.5.3:
- output dir fixed
* 0.5.2:
- static output file
* 0.5.1:
- first realase
example file:
Code: Select all
#asm
use32
org 0x0
db 'MENUET01'
dd 0x01
dd _main
dd I_END
dd 0x100000
dd 0x7fff0
dd 0x0,0x0
include 'INTRINS.ASM'
#endasm
#include "klib.h"
// CONTROLS:
#define CONTROLS 2
int control[CONTROLS];
int cont1[7] = { CheckBox,4,10,40,0x111111,0xFFFFFF,0};
int cont2[7] = { CheckBox,5,25,55,0xBBBBBB,0,0};
void main()
{
int event;
int button_id;
control[0]=&cont1[0];
control[1]=&cont2[0];
draw_window();
while(1)
{
event=get_event();
switch(event)
{
case 1: draw_window(); break;
case 2: get_button(); break;
case 3: button_id=get_button();
eventControls(control,CONTROLS,button_id);
if(button_id==1) s_quit();
break;
}
}
}
char text1[50]="THIS IS AN EXAMPLE OF C";
char text2[50]="PROGRAM IN KOLIBRIOS";
char text3[50]="";
char text4[50]="SUCCESS";
int p_text[4];
draw_window()
{
int i; /* for index */
int y;y=25;
p_text[0]=&text1[0];
p_text[1]=&text2[0];
p_text[2]=&text3[0];
p_text[3]=&text4[0];
begin_draw();
window(100,100,320,150,0x03ffffff,0x805080d0,0x005080d0);
label(8,8,0x10ddeeff,"Example application");
buttonT(50,35,60,12,0x111111,1, "Click Me!", 0xFFFFFF);
//checkbox(cbTest);
renderControls(control, CONTROLS);
for(i=0;i<4;i++)
label(20,40+(y+=10),0x000000,p_text[i]);
end_draw();
}
#asm
I_END:
#endasm
Re: Small C Compiler for KolibriOS
Posted: Fri Feb 08, 2008 1:16 pm
by camper
cool!
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Fri Feb 08, 2008 3:54 pm
by jacekm
Small C Compiler README:
Code: Select all
Small C Compiler Version 2.2
The Small C compiler translates a subset of the C language into
assembly language. It runs under PC/MS-DOS 2.1 and later. Small
C is compatible with both Small Assembler and the Microsoft
assembler MASM. Small C supports a small memory model with one
code and one data/stack segment.
Small C supports arrays of one dimension. Functions always
return integer values. External functions are automatically
declared. Initialization of global variables is supported. The
preprocessor supports #include, #define, #ifdef, #ifndef, #else,
#endif, #asm, #endasm commands . The following control
statements are supported: if, switch, case, default, break,
continue, while, for, and do/while. All expression operators are
supported. Only signed and unsigned integer and character data
types are supported. The following standard C features are not
supported: structures, fields, unions, arrays of pointers, and
casts.
Small C supports UNIX-like I/O redirection and command-line
argument passing. The Small C library includes over 80 functions
-- a nearly complete set of the standard UNIX/C repertoire.
Binary as well as character stream I/O is supported. The
formatted I/O functions printf() and scanf() are included.
Random access to files is provided. Programs can request
additional file buffering.
The compiler itself is written in Small C and is distributed
with both object and source code. As a self compiler, Small C
can be modified to work in other environments and to meet
special needs. Since everything is revealed and fully
documented, Small C has tremendous value as an educational
device. Small C uses a single pass, recursive descent parsing
algorithm. It generates p-codes for internal use, and optimizes
its output.
The Small C language and compiler are fully described in "A
Small C Compiler: Language, Usage, Theory, and Design" by James
E. Hendrix. Copies are available from:
M&T Publishing, Inc.
501 Galveston Dr.
Redwood City, CA 94063
Phone: 1 (800) 533-4372
J. E. Hendrix
P.O. Box 1435
Oxford, MS 38655
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Fri Feb 08, 2008 6:05 pm
by Leency
Oh, It looks good!
You can use skinned window
http://kolibrios.org/?p=Documentation&s ... ons&sfp=00
Good luck in your work

Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Fri Feb 08, 2008 6:06 pm
by jacekm
I've started to make KLIB.H - the library will provide easy way to use many controls.
I've just implemented CheckBox control (it's first control of my lib)

<- two CheckBox'es
How it works:
First you declare controls:
Code: Select all
// CONTROLS:
#define CONTROLS 2
int control[CONTROLS];
int cont1[7] = { CheckBox,4,10,40,0x111111,0xFFFFFF,0};
int cont2[7] = { CheckBox,5,25,55,0xBBBBBB,0,0};
/* CheckBox
0 int type
1 int id
2 int x,
3 int y,
4 int color,
5 int colorText
6 int checked - if it checked or not
*/
void main()
{
control[0]=&cont1[0];
control[1]=&cont2[0];
Event detection: (checkbox automatically changes status from ' ' to 'X')
Code: Select all
event=get_event();
switch(event)
{
case 1: draw_window(); break;
case 2: get_button(); break;
case 3: button_id=get_button();
eventControls(control,CONTROLS,button_id); <--- THE MAGIC IS HERE!!
break;
}
Render controls:
Code: Select all
draw_window(){
....
renderControls(control, CONTROLS); <--
{
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Thu Feb 14, 2008 10:50 pm
by Gluk
it's really cool. any news at moment?
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Fri Feb 15, 2008 10:14 pm
by Gluk
"Render controls:
draw_window(){
....
renderControls(control, CONTROLS); <--
{" - i think last sybmbol is wrorg..
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Sun Feb 17, 2008 12:30 pm
by jacekm
I try to implement libGUI for SCC instead of creating my own GUI library.
renderControls(control, CONTROLS); <--
{" - i think last sybmbol is wrorg.
CONTROLS is count of controls in control array.
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Sun Feb 17, 2008 12:51 pm
by Gluk
"CONTROLS is count of controls in control array." - no, i mean "{" symbol, there must be "}", i think.
Else one. Its compiler saves .asm file with the "space" at the end. Ecstention contains of 4 symbols "a","s","m","space".. it is bad, because FASM don't understand it, and i cannot make association with ".asm " files in KFAR.
P.S. Sorry my bad english..
Re: Small C Compiler for KolibriOS [v 0.5.3]
Posted: Sun Feb 17, 2008 7:08 pm
by jacekm
Gluk wrote:... Its compiler saves .asm file with the "space" at the end. Ecstention contains of 4 symbols "a","s","m","space".. it is bad, because FASM don't understand it, and i cannot make association with ".asm " files in KFAR...
Thanks to you I figured out the problem! There is link to scc version 0.5.4 in my first post. So just download the newest version and extension of output file will be all right

Re: Small C Compiler for KolibriOS [v 0.5.4]
Posted: Sat Mar 22, 2008 4:46 pm
by DonPedro
I have some questions.
1)
I must include this file? Is it required for small c compiler work?
2)
Code: Select all
get_event()
{
#asm
mov eax,10
int 0x40
#endasm
}
How does compiler known, which value returned by this function? Or return value in scc is always stored in eax?
Sorry for my English