Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 215 → Rev 214

/programs/develop/metcc/trunk/libc/proc32.inc
File deleted
/programs/develop/metcc/trunk/libc/public_stdcall.inc
File deleted
/programs/develop/metcc/trunk/libc/make.cfg
File deleted
\ No newline at end of file
/programs/develop/metcc/trunk/libc/clean.cmd
File deleted
\ No newline at end of file
/programs/develop/metcc/trunk/libc/include/stdlib.h
File deleted
\ No newline at end of file
/programs/develop/metcc/trunk/libc/include/ctype.h
File deleted
/programs/develop/metcc/trunk/libc/include/mesys.h
2,16 → 2,9
#define mesys_h
#ifdef GNUC
#define stdcall __stdcall
#define cdecl __cdecl
#else
#define stdcall __attribute__ ((__stdcall))
#define cdecl __attribute__ ((__cdecl))
#endif
 
typedef unsigned long dword;
typedef unsigned char byte;
typedef unsigned short word;
 
extern void stdcall _msys_draw_window(int xcoord,int ycoord, int xsize,
int ysize,int workcolor,int type,
int captioncolor,int windowtype,int bordercolor);
102,8 → 95,4
extern void* malloc(int);
extern void free(void*);
extern void* realloc(void*,int);
 
extern dword* stdcall _msys_cofflib_load(char* name);
extern char* stdcall _msys_cofflib_getproc(void* exp,char* sz_name);
 
#endif
/programs/develop/metcc/trunk/libc/include/stdio.h
1,7 → 1,6
#ifndef stdio_h
#define stdio_h
#include "mesys.h"
#define NULL (void*)0
typedef struct {
char* buffer;
int buffersize;
/programs/develop/metcc/trunk/libc/mesys/_mesys.asm
File deleted
\ No newline at end of file
/programs/develop/metcc/trunk/libc/mesys/cofflib.asm
File deleted
/programs/develop/metcc/trunk/libc/compile.js
1,128 → 1,118
ForReading = 1
ForWriting = 2
ForAppending = 8
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wsh = new ActiveXObject("WScript.Shell");
function alert(mes){WScript.Echo(mes);return mes}
function debug(obj){for(key in obj)alert('['+key+']="'+obj[key]+'"')}
function getFileContent(filename){
var file = fso.OpenTextFile(filename, ForReading);
var content = file.ReadAll();
file.close();
return content;
var wsh=WScript.CreateObject("WScript.Shell");
var curpath=".";
var gccpath="c:\\program files\\MinGW\\MinGW\\bin\\";
//var gccpath="cmd.exe /c ";
var gccexe="\""+gccpath+"cc1.exe"+"\" ";
var asexe="\""+gccpath+"as.exe"+"\" ";
var objcopyexe="\""+gccpath+"objcopy.exe"+"\" ";
//var gccexe=gccpath+"cc1.exe" ;
//var asexe=gccpath+"as.exe";
var scriptline="CREATE melibc.a\r\n";
 
curpath=".\\string\\";
compileasm("memmove");
compileasm("memset");
curpath=".\\mesys\\";
compileasm("backgr");
compileasm("button");
compileasm("clock");
compileasm("date");
compileasm("debug_board");
compileasm("delay");
compileasm("dga");
compileasm("draw_bar");
compileasm("draw_image");
compileasm("draw_window");
compileasm("event");
compileasm("exit");
compileasm("file_58");
compileasm("ipc");
compileasm("irq");
compileasm("keyboard");
compileasm("line");
compileasm("midi");
compileasm("pci");
compileasm("pixel");
compileasm("process");
compileasm("screen");
compileasm("sound");
compileasm("thread");
compileasm("window_redraw");
compileasm("write_text");
curpath=".\\mem\\";
compileasm("memalloc");
curpath=".\\mesys\\";
compilec("debug_board_");
curpath=".\\string\\";
compilec("memchr");
compilec("memcmp");
compilec("strcat");
compilec("strchr");
compilec("strcmp");
compilec("strcoll");
compilec("strcpy");
compilec("strcspn");
compilec("strdup");
compilec("strerror");
compilec("strlen");
compilec("strnbrk");
compilec("strncat");
compilec("strncmp");
compilec("strncpy");
compilec("strrchr");
compilec("strspn");
compilec("strstr");
compilec("strtok");
compilec("strxfrm");
curpath=".\\file\\";
compilec("fclose");
compilec("fopen");
compilec("feof");
compilec("fflush");
compilec("fgetc");
compilec("fgetpos");
compilec("fsetpos");
compilec("fputc");
compilec("fread");
compilec("fwrite");
compilec("fseek");
compilec("ftell");
compilec("rewind");
compilec("fprintf");
compilec("fscanf");
compilec("ungetc");
curpath=".\\start\\";
compileasm("start");
//linking
scriptline+="SAVE\r\n";
linko();
function compileasm(filename)
{
wsh.Run("fasm.exe "+quote(curpath+filename+".asm")+
" "+quote(curpath+filename+".o"),0,true);
addo(filename);
}
function include(filename){
eval(getFileContent(filename));
function compilec(filename)
{
wsh.Run(gccexe+"-nostdinc -I .\\include -DGNUC " + quote(curpath + filename + ".c")+
" -o " + quote(curpath + filename + ".s"),0,true);
wsh.Run(asexe+quote(curpath+filename+".s")+" -o "+quote(curpath+filename+".o"),0,true);
wsh.Run(objcopyexe+" -O elf32-i386 --remove-leading-char "+quote(curpath+filename+".o"),0,true);
addo(filename);
}
function Project(filename){
var text = getFileContent(filename);
eval("var config = {"+text+"};")
for(key in config) this[key] = config[key];
if(!this.files) this.files = [];
function getFileExt(name){
var i = name.lastIndexOf(".");
return (i==-1)? "" : name.substr(i);
function addo(filename)
{
scriptline+="ADDMOD "+curpath+filename+".o\r\n";
}
this.getFileList = function(folder){
var f = fso.GetFolder(folder);
var fc = new Enumerator(f.SubFolders);
for (; !fc.atEnd(); fc.moveNext())
function linko()
{
var name = fc.item()+"";
if(name[0]!='.' && !this.isIgnored(name))
this.getFileList(name);
//fso.DeleteFile(".\\melibc.a");
var file=fso.OpenTextFile("./script.txt",2,true);
file.Write(scriptline);
wsh.Run("cmd.exe /c ar.exe -M < ./script.txt",4,true);
}
delete fc;
fc = new Enumerator(f.Files);
for (; !fc.atEnd(); fc.moveNext())
function quote(name)
{
var name = fc.item()+"";
if(name[0]!='.' && !this.isIgnored(name))
this.files.push(name);
}
}
this.clean = function(){
var fl = new Enumerator(this.files);
var fo;
for (; !fl.atEnd(); fl.moveNext()){
var file = fl.item()
switch(getFileExt(file)){
case ".o":
case ".s":
fo = fso.GetFile(file);
fo.Delete();
break;
}
}
delete fl;
}
var objList = [];
this.compile_asm = function(filename){
var objname = filename.replace(/.\w{1,3}$/,".o");
objList.push(objname);
if(fso.FileExists(objname)) return;
wsh.Run(this.fasm+' "'+filename+'" "'+objname+'"',0,true);
}
this.compile_c = function(filename){
var objname = filename.replace(/.\w{1,3}$/,".o");
objList.push(objname);
if(fso.FileExists(objname)) return;
var asmname = filename.replace(/.\w{1,3}$/,".s");
var command = "";
if(!fso.FileExists(asmname)){
command = this.gccpath +"\\"+ this.gccexe + " -nostdinc";
if(this.include) command += " -I .\\include";
command +=" -DGNUC" +' "'+filename + '" -o "' + asmname + '"';
wsh.Run("cmd.exe /c "+command, 0, true);
}
command = this.gccpath +"\\"+ this.asexe +' "'+ asmname +'" -o "'+ objname +'"';
wsh.Run("cmd.exe /c "+command, 0, true);
command = this.gccpath +"\\"+ this.objcopyexe +' -O elf32-i386 --remove-leading-char "'+ objname +'"';
wsh.Run("cmd.exe /c "+command, 0, true);
}
this.build = function(){
var fl = new Enumerator(this.files);
for (; !fl.atEnd(); fl.moveNext()){
var file = fl.item()
switch(getFileExt(file)){
case ".c": this.compile_c(file);break;
case ".asm": this.compile_asm(file);break;
case ".o": objList.push(file);break;
}
}
delete fl;
fl = new Enumerator(objList);
/* var file = fso.CreateTextFile("OBJLIST.TXT", true);
file.Write("CREATE "+this.dstpath+'\\'+this.name+".a\r\n");
for (; !fl.atEnd(); fl.moveNext()){file.Write("ADDMOD "+fl.item()+"\r\n");}
file.Write("SAVE\r\t");
file.Close();
wsh.Run(this.gccpath+"\\ar.exe -M < OBJLIST.TXT", 0, true);*/
var ar = wsh.Exec(this.gccpath+"\\ar.exe -M")
ar.StdIn.Write("CREATE "+this.dstpath+'\\'+this.name+".a\r\n");
for (; !fl.atEnd(); fl.moveNext()){ar.StdIn.Write("ADDMOD "+fl.item()+"\r\n");}
ar.StdIn.Write("SAVE\r\t");
}
this.rebuild = function(){
this.clean();
this.build();
}
this.isIgnored = function(value){
for(var i=0; i<this.ignored.length; i++)
if (this.ignored[i]==value||this.ignored[i]==getFileExt(value)) return true;
return false;
}
this.nothing = function(){alert("Hello")}
this.getFileList(this.srcpath);
}
 
try{var confFile = WScript.Arguments(1);}catch(e){var confFile = "make.cfg";}
try{var action = WScript.Arguments(0);}catch(e){var action = "build";}
 
var conf = new Project(confFile);
conf[action]();
 
if(conf.autoclean && action != "clean"){conf["clean"]();}
alert("Done");
return "\""+name+"\"";
}
/programs/develop/metcc/trunk/libc/start/debug-fdo.inc
File deleted
/programs/develop/metcc/trunk/libc/start/macros.inc
File deleted
\ No newline at end of file
/programs/develop/metcc/trunk/libc/start/start.asm
3,12 → 3,8
public start
extrn mf_init
extrn main
 
__DEBUG__ equ 1
__DEBUG_LEVEL__ equ 1
 
include 'DEBUG-FDO.INC'
 
;include 'debug2.inc'
__DEBUG__=0
virtual at 0
db 'MENUET01' ; 1. Magic number (8 bytes)
dd 0x01 ; 2. Version of executable file
20,10 → 16,10
hpath dd 0x0 ; 8. Pointer to program path
end virtual
start:
DEBUGF 1,'Start programm\n'
;DEBUGF 'Start programm\n'
xor eax,eax
call mf_init
DEBUGF 1,' path "%s"\n params "%s"\n', path, params
;DEBUGF ' path "%s"\n params "%s"\n', .path, .params
; check for overflow
mov al, [path+buf_len-1]
or al, [params+buf_len-1]
82,25 → 78,25
jmp .parse
 
.run:
DEBUGF 1,'call main(%x, %x) with params:\n', [argc], argv
;DEBUGF 'call main(%x, %x) with params:\n', [argc], argv
if __DEBUG__ = 1
mov ecx, [argc]
@@:
lea esi, [ecx * 4 + argv-4]
DEBUGF 1,'%d) "%s"\n', cx, [esi]
DEBUGF '0x%x) "%s"\n', cx, [esi]
loop @b
end if
push [argc]
push argv
push [argc]
call main
.exit:
DEBUGF 1,'Exit from prog with code: %x\n', eax;
;DEBUGF 'Exit from prog\n';
xor eax,eax
dec eax
int 0x40
dd -1
.crash:
DEBUGF 1,'E:buffer overflowed\n'
;DEBUGF 'E:buffer overflowed\n'
jmp .exit
;============================
push_param:
130,5 → 126,5
path rb buf_len
params rb buf_len
 
section '.data'
include_debug_strings ; ALWAYS present in data section
;section '.data'
;include_debug_strings ; ALWAYS present in data section
/programs/develop/metcc/trunk/libc/string/is.c
File deleted
/programs/develop/metcc/trunk/libc/string/atoi.c
File deleted
/programs/develop/metcc/trunk/libc/string/itoa.c
File deleted
/programs/develop/metcc/trunk/libc/string/itoab.c
File deleted
/programs/develop/metcc/trunk/libc/string/toupper.c
File deleted
/programs/develop/metcc/trunk/libc/string/atoib.cpp
File deleted
/programs/develop/metcc/trunk/libc/string/tolower.c
File deleted
/programs/develop/metcc/trunk/libc/string/strcat.c
2,7 → 2,12
{
char* res;
res=strDest;
while (*strDest++) ;
while (*strDest++ = *strSource++) ;
while (*strDest!='\0') strDest++;
while (*strSource!='\0')
{
*strDest=*strSource;
strDest++;
strSource++;
}
return res;
}
/programs/develop/metcc/trunk/libc/string/strchr.c
1,6 → 1,6
char* strchr(const char* string, int c)
{
while (*string)
while (*string!='\0')
{
if (*string==c)
return (char*)string;
/programs/develop/metcc/trunk/libc/string/strcpy.c
2,6 → 2,13
{
char* res;
res=strDest;
while(*strDest++ == strSource++) ;
while(1)
{
*strDest=*strSource;
if (*strSource=='\0')
break;
strDest++;
strSource++;
}
return res;
}
}
/programs/develop/metcc/trunk/libc/string/strlen.c
2,6 → 2,10
{
int i;
i=0;
while (*string!++) i++;
while (*string!='\0')
{
i++;
string++;
}
return i;
}
/programs/develop/metcc/trunk/libc/string/strncat.c
2,12 → 2,13
{
char* res;
res=strDest;
while (*strDest++) ;
while(count-->0)
while (*strDest!='\0') strDest++;
while (count>0 && *strSource!='\0')
{
if(*strDest++ = *strSource++) continue;
return(res);
*strDest=*strSource;
count--;
strDest++;
strSource++;
}
*strDest = 0;
return res;
}
}
/programs/develop/metcc/trunk/libc/string/strncmp.c
1,12 → 1,14
int strncmp(const char* string1, const char* string2, int count)
{
while(count>0 && *string1==*string2)
while(count>0)
{
if (*string1) return 0;
++string1;
++string2;
--count;
if (*string1<*string2)
return -1;
if (*string1>*string2)
return 1;
if (*string1=='\0')
return 0;
count--;
}
if(count) return (*string1 - *string2);
return 0;
}
}
/programs/develop/metcc/trunk/libc/string/strncpy.c