small fixes. need more

git-svn-id: svn://kolibrios.org@6410 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
siemargl 2016-04-27 19:59:20 +00:00
parent a1265dabee
commit 845d2f0618
10 changed files with 84 additions and 79 deletions

View File

@ -6,10 +6,10 @@ echo ####################################################
rem #### CONFIG SECTION ####
set LIBNAME=libck.a
set INCLUDE=include
set CC=
set CC=kos32-tcc
set CFLAGS=-c -nostdinc -DGNUC -I"%cd%\%INCLUDE%"
set AR=
set ASM=
set AR=kos32-ar
set ASM=fasm
set dirs=stdio memory kolibrisys string stdlib
rem #### END OF CONFIG SECTION ####

View File

@ -6,7 +6,7 @@ include 'proc32.inc'
public memcpy
public memmove
proc memcpy stdcall, to:dword,from:dword,count:dword
proc memcpy c, to:dword,from:dword,count:dword
mov ecx,[count]
test ecx,ecx
@ -20,7 +20,7 @@ proc memcpy stdcall, to:dword,from:dword,count:dword
ret
endp
proc memmove stdcall, to:dword,from:dword,count:dword
proc memmove c, to:dword,from:dword,count:dword
mov ecx,[count]
test ecx,ecx

View File

@ -2,7 +2,7 @@ char* strcat(char* strDest, const char* strSource)
{
char* res;
res=strDest;
while (*strDest++) ;
while (*strDest) strDest++;
while (*strDest++ = *strSource++) ;
return res;
}

View File

@ -2,6 +2,6 @@ char* strcpy(char* strDest,char* strSource)
{
char* res;
res=strDest;
while(*strDest++ == strSource++) ;
while(*strDest++ = *strSource++) ;
return res;
}

View File

@ -1,4 +1,4 @@
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
include $(MENUETDEV)/makefiles/Makefile_for_program
include Makefile_for_program

View File

@ -5,3 +5,7 @@
#define TCC_VERSION "0.9.23"
//#define TCC_TARGET_PE
#define TCC_TARGET_MEOS
/* enable bound checking code */
//#define CONFIG_TCC_BCHECK 1

View File

@ -8,68 +8,68 @@ public console_exit
align 4
console_init:
pushad
pushad
mov eax,[console_init_status]
test eax,eax
jnz console_initializated
mov eax,[console_init_status]
test eax,eax
jnz console_initializated
mov [console_init_status],1
mov [console_init_status],1
mov eax,68
mov ebx,19
mov ecx,console_path
int 0x40
mov eax,68
mov ebx,19
mov ecx,console_path
int 0x40
test eax,eax
jz console_not_loaded
test eax,eax
jz console_not_loaded
mov ebx,[eax+4]
mov [con_start],ebx
mov ebx,[eax+4]
mov [con_start],ebx
mov ebx,[eax+4+16]
mov [con_init],ebx
mov ebx,[eax+4+16]
mov [con_init],ebx
mov ebx,[eax+4+32]
mov [con_printf],ebx
mov ebx,[eax+4+32]
mov [con_printf],ebx
push 1
call [con_start]
push 1
call [con_start]
push caption
push -1
push -1
push -1
push -1
call [con_init]
push caption
push -1
push -1
push -1
push -1
call [con_init]
console_not_loaded:
console_not_loaded:
console_initializated:
console_initializated:
popad
popad
ret
ret
align 4
console_printf:
pop [return_addres]
pop [return_addres]
call [con_printf]
;add esp,8
call [con_printf]
;add esp,8
push [return_addres]
push [return_addres]
ret
ret
align 4
console_exit:
push 0
call [con_exit]
push 0
call [con_exit]
ret
ret
;-----------------------------
@ -77,9 +77,9 @@ console_path db '/sys/dll/console.obj',0
caption db 'Console',0
align 4
con_start rd 1
con_init rd 1
con_printf rd 1
con_exit rd 1
console_init_status rd 1
return_addres rd 1
con_start rd 1
con_init rd 1
con_printf rd 1
con_exit rd 1
console_init_status rd 1
return_addres rd 1

View File

@ -399,7 +399,7 @@ long long __moddi3(long long u, long long v)
if (vv.s.high < 0)
vv.ll = __negdi2 (vv.ll);
__udivmoddi4 (uu.ll, vv.ll, &w);
__udivmoddi4 (uu.ll, vv.ll, (UDWtype *) &w);
if (c)
w = __negdi2 (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.low = 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;
}
return u.ll;

View File

@ -8,14 +8,14 @@ __DEBUG__=0
;start_:
virtual at 0
db 'MENUET01' ; 1. Magic number (8 bytes)
dd 0x01 ; 2. Version of executable file
dd start ; 3. Start address
dd 0x0 ; 4. Size of image
dd 0x100000 ; 5. Size of needed memory
dd 0x100000 ; 6. Pointer to stack
hparams dd 0x0 ; 7. Pointer to program arguments
hpath dd 0x0 ; 8. Pointer to program path
db 'MENUET01' ; 1. Magic number (8 bytes)
dd 0x01 ; 2. Version of executable file
dd start ; 3. Start address
dd 0x0 ; 4. Size of image
dd 0x100000 ; 5. Size of needed memory
dd 0x100000 ; 6. Pointer to stack
hparams dd 0x0 ; 7. Pointer to program arguments
hpath dd 0x0 ; 8. Pointer to program path
end virtual
start:
@ -28,12 +28,12 @@ start:
;DEBUGF ' path "%s"\n params "%s"\n', .path, .params
; check for overflow
mov al, [path+buf_len-1]
or al, [params+buf_len-1]
or al, [params+buf_len-1]
jnz .crash
; check if path written by OS
mov eax, [hparams]
test eax, eax
jz .without_path
jz .without_path
mov eax, path
.without_path:
mov esi, eax
@ -41,21 +41,21 @@ start:
; retrieving parameters
mov esi, params
xor edx, edx ; dl - èä¸ò ïàðàìåòð(1) èëè ðàçäåëèòåëè(0)
; dh - ñèìâîë ñ êîòîðîãî íà÷àëñÿ ïàðàìåòð (1 êàâû÷êè, 0 îñòàëüíîå)
; dh - ñèìâîë ñ êîòîðîãî íà÷àëñÿ ïàðàìåòð (1 êàâû÷êè, 0 îñòàëüíîå)
mov ecx, 1 ; cl = 1
; ch = 0 ïðîñòî íîëü
; ch = 0 ïðîñòî íîëü
.parse:
lodsb
test al, al
jz .run
jz .run
test dl, dl
jnz .findendparam
;{åñëè áûë ðàçäåëèòåëü
;{åñëè áûë ðàçäåëèòåëü
cmp al, ' '
jz .parse ;çàãðóæåí ïðîáåë, ãðóçèì ñëåäóþùèé ñèìâîë
jz .parse ;çàãðóæåí ïðîáåë, ãðóçèì ñëåäóþùèé ñèìâîë
mov dl, cl ;íà÷èíàåòñÿ ïàðàìåòð
cmp al, '"'
jz @f ;çàãðóæåíû êàâû÷êè
jz @f ;çàãðóæåíû êàâû÷êè
mov dh, ch ;ïàðàìåòð áåç êàâû÷åê
dec esi
call push_param
@ -69,9 +69,9 @@ start:
.findendparam:
test dh, dh
jz @f ; áåç êàâû÷åê
jz @f ; áåç êàâû÷åê
cmp al, '"'
jz .clear
jz .clear
jmp .parse
@@:
cmp al, ' '
@ -100,7 +100,7 @@ end if
xor eax,eax
dec eax
int 0x40
dd -1
dd -1
.crash:
;DEBUGF 'E:buffer overflowed\n'
jmp .exit
@ -127,10 +127,10 @@ public path as '__path'
section '.bss'
buf_len = 0x400
max_parameters=0x20
argc rd 1
argv rd max_parameters
path rb buf_len
params rb buf_len
argc rd 1
argv rd max_parameters
path rb buf_len
params rb buf_len
;section '.data'
;include_debug_strings ; ALWAYS present in data section

View File

@ -1034,7 +1034,8 @@ static inline void tcc_free(void *ptr)
#ifdef MEM_DEBUG
mem_cur_size -= malloc_usable_size(ptr);
#endif
free(ptr);
//2016-04-27 siemargl commented to fix crash temporally. Need to fix
// free(ptr);
}
static void *tcc_malloc(unsigned long size)
@ -10591,7 +10592,7 @@ int parse_args(TCCState *s, int argc, char **argv)
return optind;
}
int app_main(int argc, char **argv)
int main(int argc, char **argv)
{
int i;
TCCState *s;