small fixes. need more
git-svn-id: svn://kolibrios.org@6410 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a1265dabee
commit
845d2f0618
@ -6,10 +6,10 @@ echo ####################################################
|
|||||||
rem #### CONFIG SECTION ####
|
rem #### CONFIG SECTION ####
|
||||||
set LIBNAME=libck.a
|
set LIBNAME=libck.a
|
||||||
set INCLUDE=include
|
set INCLUDE=include
|
||||||
set CC=
|
set CC=kos32-tcc
|
||||||
set CFLAGS=-c -nostdinc -DGNUC -I"%cd%\%INCLUDE%"
|
set CFLAGS=-c -nostdinc -DGNUC -I"%cd%\%INCLUDE%"
|
||||||
set AR=
|
set AR=kos32-ar
|
||||||
set ASM=
|
set ASM=fasm
|
||||||
set dirs=stdio memory kolibrisys string stdlib
|
set dirs=stdio memory kolibrisys string stdlib
|
||||||
rem #### END OF CONFIG SECTION ####
|
rem #### END OF CONFIG SECTION ####
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ include 'proc32.inc'
|
|||||||
public memcpy
|
public memcpy
|
||||||
public memmove
|
public memmove
|
||||||
|
|
||||||
proc memcpy stdcall, to:dword,from:dword,count:dword
|
proc memcpy c, to:dword,from:dword,count:dword
|
||||||
|
|
||||||
mov ecx,[count]
|
mov ecx,[count]
|
||||||
test ecx,ecx
|
test ecx,ecx
|
||||||
@ -20,7 +20,7 @@ proc memcpy stdcall, to:dword,from:dword,count:dword
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
proc memmove stdcall, to:dword,from:dword,count:dword
|
proc memmove c, to:dword,from:dword,count:dword
|
||||||
|
|
||||||
mov ecx,[count]
|
mov ecx,[count]
|
||||||
test ecx,ecx
|
test ecx,ecx
|
||||||
|
@ -2,7 +2,7 @@ char* strcat(char* strDest, const char* strSource)
|
|||||||
{
|
{
|
||||||
char* res;
|
char* res;
|
||||||
res=strDest;
|
res=strDest;
|
||||||
while (*strDest++) ;
|
while (*strDest) strDest++;
|
||||||
while (*strDest++ = *strSource++) ;
|
while (*strDest++ = *strSource++) ;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@ char* strcpy(char* strDest,char* strSource)
|
|||||||
{
|
{
|
||||||
char* res;
|
char* res;
|
||||||
res=strDest;
|
res=strDest;
|
||||||
while(*strDest++ == strSource++) ;
|
while(*strDest++ = *strSource++) ;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
OUTFILE = ktcc.kex
|
OUTFILE = ktcc.kex
|
||||||
OBJS = tcc.o console.o
|
OBJS = tcc.o console.o getcwd.o
|
||||||
CGLAGS =-O2 -g -Wall -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0 -fno-strict-aliasing
|
CGLAGS =-O2 -g -Wall -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0 -fno-strict-aliasing
|
||||||
include $(MENUETDEV)/makefiles/Makefile_for_program
|
include Makefile_for_program
|
||||||
|
@ -5,3 +5,7 @@
|
|||||||
#define TCC_VERSION "0.9.23"
|
#define TCC_VERSION "0.9.23"
|
||||||
//#define TCC_TARGET_PE
|
//#define TCC_TARGET_PE
|
||||||
#define TCC_TARGET_MEOS
|
#define TCC_TARGET_MEOS
|
||||||
|
|
||||||
|
/* enable bound checking code */
|
||||||
|
//#define CONFIG_TCC_BCHECK 1
|
||||||
|
|
||||||
|
@ -8,68 +8,68 @@ public console_exit
|
|||||||
align 4
|
align 4
|
||||||
console_init:
|
console_init:
|
||||||
|
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
mov eax,[console_init_status]
|
mov eax,[console_init_status]
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jnz console_initializated
|
jnz console_initializated
|
||||||
|
|
||||||
mov [console_init_status],1
|
mov [console_init_status],1
|
||||||
|
|
||||||
mov eax,68
|
mov eax,68
|
||||||
mov ebx,19
|
mov ebx,19
|
||||||
mov ecx,console_path
|
mov ecx,console_path
|
||||||
int 0x40
|
int 0x40
|
||||||
|
|
||||||
test eax,eax
|
test eax,eax
|
||||||
jz console_not_loaded
|
jz console_not_loaded
|
||||||
|
|
||||||
mov ebx,[eax+4]
|
mov ebx,[eax+4]
|
||||||
mov [con_start],ebx
|
mov [con_start],ebx
|
||||||
|
|
||||||
mov ebx,[eax+4+16]
|
mov ebx,[eax+4+16]
|
||||||
mov [con_init],ebx
|
mov [con_init],ebx
|
||||||
|
|
||||||
mov ebx,[eax+4+32]
|
mov ebx,[eax+4+32]
|
||||||
mov [con_printf],ebx
|
mov [con_printf],ebx
|
||||||
|
|
||||||
push 1
|
push 1
|
||||||
call [con_start]
|
call [con_start]
|
||||||
|
|
||||||
push caption
|
push caption
|
||||||
push -1
|
push -1
|
||||||
push -1
|
push -1
|
||||||
push -1
|
push -1
|
||||||
push -1
|
push -1
|
||||||
call [con_init]
|
call [con_init]
|
||||||
|
|
||||||
console_not_loaded:
|
console_not_loaded:
|
||||||
|
|
||||||
console_initializated:
|
console_initializated:
|
||||||
|
|
||||||
popad
|
popad
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
console_printf:
|
console_printf:
|
||||||
|
|
||||||
pop [return_addres]
|
pop [return_addres]
|
||||||
|
|
||||||
call [con_printf]
|
call [con_printf]
|
||||||
;add esp,8
|
;add esp,8
|
||||||
|
|
||||||
push [return_addres]
|
push [return_addres]
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
console_exit:
|
console_exit:
|
||||||
|
|
||||||
push 0
|
push 0
|
||||||
call [con_exit]
|
call [con_exit]
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------
|
;-----------------------------
|
||||||
@ -77,9 +77,9 @@ console_path db '/sys/dll/console.obj',0
|
|||||||
caption db 'Console',0
|
caption db 'Console',0
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
con_start rd 1
|
con_start rd 1
|
||||||
con_init rd 1
|
con_init rd 1
|
||||||
con_printf rd 1
|
con_printf rd 1
|
||||||
con_exit rd 1
|
con_exit rd 1
|
||||||
console_init_status rd 1
|
console_init_status rd 1
|
||||||
return_addres rd 1
|
return_addres rd 1
|
||||||
|
@ -399,7 +399,7 @@ long long __moddi3(long long u, long long v)
|
|||||||
if (vv.s.high < 0)
|
if (vv.s.high < 0)
|
||||||
vv.ll = __negdi2 (vv.ll);
|
vv.ll = __negdi2 (vv.ll);
|
||||||
|
|
||||||
__udivmoddi4 (uu.ll, vv.ll, &w);
|
__udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
|
||||||
if (c)
|
if (c)
|
||||||
w = __negdi2 (w);
|
w = __negdi2 (w);
|
||||||
return w;
|
return w;
|
||||||
@ -466,7 +466,7 @@ long long __shldi3(long long a, int b)
|
|||||||
u.s.high = (unsigned)u.s.low << (b - 32);
|
u.s.high = (unsigned)u.s.low << (b - 32);
|
||||||
u.s.low = 0;
|
u.s.low = 0;
|
||||||
} else if (b != 0) {
|
} else if (b != 0) {
|
||||||
u.s.high = ((unsigned)u.s.high << b) | (u.s.low >> (32 - b));
|
u.s.high = ((unsigned)u.s.high << b) | ((unsigned)u.s.low >> (32 - b));
|
||||||
u.s.low = (unsigned)u.s.low << b;
|
u.s.low = (unsigned)u.s.low << b;
|
||||||
}
|
}
|
||||||
return u.ll;
|
return u.ll;
|
||||||
|
@ -8,14 +8,14 @@ __DEBUG__=0
|
|||||||
|
|
||||||
;start_:
|
;start_:
|
||||||
virtual at 0
|
virtual at 0
|
||||||
db 'MENUET01' ; 1. Magic number (8 bytes)
|
db 'MENUET01' ; 1. Magic number (8 bytes)
|
||||||
dd 0x01 ; 2. Version of executable file
|
dd 0x01 ; 2. Version of executable file
|
||||||
dd start ; 3. Start address
|
dd start ; 3. Start address
|
||||||
dd 0x0 ; 4. Size of image
|
dd 0x0 ; 4. Size of image
|
||||||
dd 0x100000 ; 5. Size of needed memory
|
dd 0x100000 ; 5. Size of needed memory
|
||||||
dd 0x100000 ; 6. Pointer to stack
|
dd 0x100000 ; 6. Pointer to stack
|
||||||
hparams dd 0x0 ; 7. Pointer to program arguments
|
hparams dd 0x0 ; 7. Pointer to program arguments
|
||||||
hpath dd 0x0 ; 8. Pointer to program path
|
hpath dd 0x0 ; 8. Pointer to program path
|
||||||
end virtual
|
end virtual
|
||||||
|
|
||||||
start:
|
start:
|
||||||
@ -28,12 +28,12 @@ start:
|
|||||||
;DEBUGF ' path "%s"\n params "%s"\n', .path, .params
|
;DEBUGF ' path "%s"\n params "%s"\n', .path, .params
|
||||||
; check for overflow
|
; check for overflow
|
||||||
mov al, [path+buf_len-1]
|
mov al, [path+buf_len-1]
|
||||||
or al, [params+buf_len-1]
|
or al, [params+buf_len-1]
|
||||||
jnz .crash
|
jnz .crash
|
||||||
; check if path written by OS
|
; check if path written by OS
|
||||||
mov eax, [hparams]
|
mov eax, [hparams]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .without_path
|
jz .without_path
|
||||||
mov eax, path
|
mov eax, path
|
||||||
.without_path:
|
.without_path:
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
@ -41,21 +41,21 @@ start:
|
|||||||
; retrieving parameters
|
; retrieving parameters
|
||||||
mov esi, params
|
mov esi, params
|
||||||
xor edx, edx ; dl - èä¸ò ïàðàìåòð(1) èëè ðàçäåëèòåëè(0)
|
xor edx, edx ; dl - èä¸ò ïàðàìåòð(1) èëè ðàçäåëèòåëè(0)
|
||||||
; dh - ñèìâîë ñ êîòîðîãî íà÷àëñÿ ïàðàìåòð (1 êàâû÷êè, 0 îñòàëüíîå)
|
; dh - ñèìâîë ñ êîòîðîãî íà÷àëñÿ ïàðàìåòð (1 êàâû÷êè, 0 îñòàëüíîå)
|
||||||
mov ecx, 1 ; cl = 1
|
mov ecx, 1 ; cl = 1
|
||||||
; ch = 0 ïðîñòî íîëü
|
; ch = 0 ïðîñòî íîëü
|
||||||
.parse:
|
.parse:
|
||||||
lodsb
|
lodsb
|
||||||
test al, al
|
test al, al
|
||||||
jz .run
|
jz .run
|
||||||
test dl, dl
|
test dl, dl
|
||||||
jnz .findendparam
|
jnz .findendparam
|
||||||
;{åñëè áûë ðàçäåëèòåëü
|
;{åñëè áûë ðàçäåëèòåëü
|
||||||
cmp al, ' '
|
cmp al, ' '
|
||||||
jz .parse ;çàãðóæåí ïðîáåë, ãðóçèì ñëåäóþùèé ñèìâîë
|
jz .parse ;çàãðóæåí ïðîáåë, ãðóçèì ñëåäóþùèé ñèìâîë
|
||||||
mov dl, cl ;íà÷èíàåòñÿ ïàðàìåòð
|
mov dl, cl ;íà÷èíàåòñÿ ïàðàìåòð
|
||||||
cmp al, '"'
|
cmp al, '"'
|
||||||
jz @f ;çàãðóæåíû êàâû÷êè
|
jz @f ;çàãðóæåíû êàâû÷êè
|
||||||
mov dh, ch ;ïàðàìåòð áåç êàâû÷åê
|
mov dh, ch ;ïàðàìåòð áåç êàâû÷åê
|
||||||
dec esi
|
dec esi
|
||||||
call push_param
|
call push_param
|
||||||
@ -69,9 +69,9 @@ start:
|
|||||||
|
|
||||||
.findendparam:
|
.findendparam:
|
||||||
test dh, dh
|
test dh, dh
|
||||||
jz @f ; áåç êàâû÷åê
|
jz @f ; áåç êàâû÷åê
|
||||||
cmp al, '"'
|
cmp al, '"'
|
||||||
jz .clear
|
jz .clear
|
||||||
jmp .parse
|
jmp .parse
|
||||||
@@:
|
@@:
|
||||||
cmp al, ' '
|
cmp al, ' '
|
||||||
@ -100,7 +100,7 @@ end if
|
|||||||
xor eax,eax
|
xor eax,eax
|
||||||
dec eax
|
dec eax
|
||||||
int 0x40
|
int 0x40
|
||||||
dd -1
|
dd -1
|
||||||
.crash:
|
.crash:
|
||||||
;DEBUGF 'E:buffer overflowed\n'
|
;DEBUGF 'E:buffer overflowed\n'
|
||||||
jmp .exit
|
jmp .exit
|
||||||
@ -127,10 +127,10 @@ public path as '__path'
|
|||||||
section '.bss'
|
section '.bss'
|
||||||
buf_len = 0x400
|
buf_len = 0x400
|
||||||
max_parameters=0x20
|
max_parameters=0x20
|
||||||
argc rd 1
|
argc rd 1
|
||||||
argv rd max_parameters
|
argv rd max_parameters
|
||||||
path rb buf_len
|
path rb buf_len
|
||||||
params rb buf_len
|
params rb buf_len
|
||||||
|
|
||||||
;section '.data'
|
;section '.data'
|
||||||
;include_debug_strings ; ALWAYS present in data section
|
;include_debug_strings ; ALWAYS present in data section
|
@ -1034,7 +1034,8 @@ static inline void tcc_free(void *ptr)
|
|||||||
#ifdef MEM_DEBUG
|
#ifdef MEM_DEBUG
|
||||||
mem_cur_size -= malloc_usable_size(ptr);
|
mem_cur_size -= malloc_usable_size(ptr);
|
||||||
#endif
|
#endif
|
||||||
free(ptr);
|
//2016-04-27 siemargl commented to fix crash temporally. Need to fix
|
||||||
|
// free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *tcc_malloc(unsigned long size)
|
static void *tcc_malloc(unsigned long size)
|
||||||
@ -10591,7 +10592,7 @@ int parse_args(TCCState *s, int argc, char **argv)
|
|||||||
return optind;
|
return optind;
|
||||||
}
|
}
|
||||||
|
|
||||||
int app_main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
TCCState *s;
|
TCCState *s;
|
||||||
|
Loading…
Reference in New Issue
Block a user