forked from KolibriOS/kolibrios
initial import of metcc project
git-svn-id: svn://kolibrios.org@145 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
156
programs/develop/metcc/trunk/libc/string/_mesys.asm
Normal file
156
programs/develop/metcc/trunk/libc/string/_mesys.asm
Normal file
@@ -0,0 +1,156 @@
|
||||
format ELF
|
||||
section '.text' executable
|
||||
|
||||
public _msys_draw_window
|
||||
_msys_draw_window:
|
||||
;arg1 - xcoord
|
||||
;arg2 - ycoord
|
||||
;arg3 - xsize
|
||||
;arg4 - ysize
|
||||
;arg5 - workcolor
|
||||
;arg6 - type
|
||||
;arg7 - captioncolor
|
||||
;arg8 - windowtype
|
||||
;arg9 - bordercolor
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
push ebx esi edi
|
||||
mov ebx,[ebp+8]
|
||||
shl ebx,16
|
||||
mov bx,[ebp+16]
|
||||
mov ecx,[ebp+12]
|
||||
shl ecx,16
|
||||
mov cx,[ebp+20]
|
||||
mov edx,[ebp+28]
|
||||
shl edx,24
|
||||
add edx,[ebp+24]
|
||||
mov esi,[ebp+36]
|
||||
shl esi,24
|
||||
add esi,[ebp+32]
|
||||
mov edi,[ebp+40]
|
||||
xor eax,eax
|
||||
int 0x40
|
||||
pop edi esi ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
public _msys_read_file
|
||||
_msys_read_file:
|
||||
;arg1 - file name
|
||||
;arg2 - file offset
|
||||
;arg3 - size to read
|
||||
;arg4 - data
|
||||
;arg5 - temp buffer
|
||||
;arg6 - file size
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
xor eax,eax
|
||||
mov [file_struct.operation],eax
|
||||
mov eax,[ebp+12]
|
||||
mov [file_struct.offset],eax
|
||||
mov eax,[ebp+16]
|
||||
mov [file_struct.offset],eax
|
||||
mov eax,[ebp+20]
|
||||
mov [file_struct.offset],eax
|
||||
mov [file_struct.temp_buffer],temp_buffer
|
||||
mov edx,[ebp+8]
|
||||
call copy_file_name
|
||||
push ebx
|
||||
mov ebx,file_struct
|
||||
mov eax,58
|
||||
int 0x40
|
||||
mov ecx,[ebp+28]
|
||||
test ecx,ecx
|
||||
jz .no_file_size
|
||||
mov [ecx],ebx
|
||||
.no_file_size:
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
copy_file_name:
|
||||
push esi edi
|
||||
cld
|
||||
mov edi,edx
|
||||
xor eax,eax
|
||||
xor ecx,ecx
|
||||
dec ecx
|
||||
repnz scasb
|
||||
not ecx
|
||||
mov edi,file_struct.path
|
||||
mov esi,edx
|
||||
rep movsb
|
||||
pop edi esi
|
||||
ret
|
||||
|
||||
public _msys_write_file
|
||||
_msys_write_file:
|
||||
;arg1 - file name
|
||||
;arg2 - size
|
||||
;arg3 - data
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
xor eax,eax
|
||||
mov [file_struct.offset],eax
|
||||
inc eax
|
||||
mov [file_struct.operation],eax
|
||||
mov eax,[ebp+12]
|
||||
mov [file_struct.size],eax
|
||||
mov eax,[ebp+16]
|
||||
mov [file_struct.data],eax
|
||||
mov [file_struct.temp_buffer],temp_buffer
|
||||
mov edx,[ebp+8]
|
||||
call copy_file_name
|
||||
push ebx
|
||||
mov eax,58
|
||||
mov ebx,file_struct
|
||||
int 0x40
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
public _msys_run_program
|
||||
_msys_run_program:
|
||||
;arg1 - program name
|
||||
;arg2 - parameters
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
mov [file_struct.operation],16
|
||||
xor eax,eax
|
||||
mov [file_struct.offset],eax
|
||||
mov [file_struct.data],eax
|
||||
mov eax,[ebp+12]
|
||||
mov [file_struct.param],eax
|
||||
mov [file_struct.temp_buffer],temp_buffer;
|
||||
mov edx,[ebp+8]
|
||||
call copy_file_name
|
||||
push ebx
|
||||
mov eax,58
|
||||
mov ebx,file_struct
|
||||
int 0x40
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
public _msys_debug_out
|
||||
_msys_debug_out:
|
||||
;arg1 - char to out
|
||||
push ebx
|
||||
mov ecx,[esp+8]
|
||||
mov ebx,1
|
||||
mov eax,63
|
||||
int 0x40
|
||||
pop ebx
|
||||
ret
|
||||
section '.data' writeable
|
||||
section '.bss' writeable
|
||||
file_struct:
|
||||
.operation rd 1
|
||||
.offset rd 1
|
||||
.param:
|
||||
.size rd 1
|
||||
.data rd 1
|
||||
.temp_buffer rd 1
|
||||
.path rb 1024
|
||||
temp_buffer rb 4096
|
||||
|
10
programs/develop/metcc/trunk/libc/string/memchr.c
Normal file
10
programs/develop/metcc/trunk/libc/string/memchr.c
Normal file
@@ -0,0 +1,10 @@
|
||||
void* memchr(const void* buf,int c,int count)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<count;i++)
|
||||
if (*(char*)buf==c)
|
||||
return (void*)buf;
|
||||
else
|
||||
buf++;
|
||||
return (void*)0;
|
||||
}
|
13
programs/develop/metcc/trunk/libc/string/memcmp.c
Normal file
13
programs/develop/metcc/trunk/libc/string/memcmp.c
Normal file
@@ -0,0 +1,13 @@
|
||||
typedef unsigned char uc;
|
||||
int memcmp(const void* buf1,const void* buf2,int count)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<count;i++)
|
||||
{
|
||||
if (*(uc*)buf1<*(uc*)buf2)
|
||||
return -1;
|
||||
if (*(uc*)buf1>*(uc*)buf2)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
16
programs/develop/metcc/trunk/libc/string/memmove.asm
Normal file
16
programs/develop/metcc/trunk/libc/string/memmove.asm
Normal file
@@ -0,0 +1,16 @@
|
||||
format ELF
|
||||
section '.text' executable
|
||||
public memcpy
|
||||
public memmove
|
||||
memcpy:
|
||||
memmove:
|
||||
push esi edi
|
||||
mov edi,[esp+12]
|
||||
mov esi,[esp+16]
|
||||
mov ecx,[esp+20]
|
||||
jecxz .no_copy
|
||||
cld
|
||||
rep movsb
|
||||
.no_copy:
|
||||
pop edi esi
|
||||
ret
|
15
programs/develop/metcc/trunk/libc/string/memset.asm
Normal file
15
programs/develop/metcc/trunk/libc/string/memset.asm
Normal file
@@ -0,0 +1,15 @@
|
||||
format ELF
|
||||
section '.text' executable
|
||||
public memset
|
||||
memset:
|
||||
push edi
|
||||
mov edi,[esp+8]
|
||||
mov eax,[esp+12]
|
||||
mov ecx,[esp+16]
|
||||
jecxz .no_set
|
||||
cld
|
||||
rep stosb
|
||||
.no_set:
|
||||
pop edi
|
||||
ret
|
||||
|
13
programs/develop/metcc/trunk/libc/string/strcat.c
Normal file
13
programs/develop/metcc/trunk/libc/string/strcat.c
Normal file
@@ -0,0 +1,13 @@
|
||||
char* strcat(char* strDest, const char* strSource)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while (*strDest!='\0') strDest++;
|
||||
while (*strSource!='\0')
|
||||
{
|
||||
*strDest=*strSource;
|
||||
strDest++;
|
||||
strSource++;
|
||||
}
|
||||
return res;
|
||||
}
|
10
programs/develop/metcc/trunk/libc/string/strchr.c
Normal file
10
programs/develop/metcc/trunk/libc/string/strchr.c
Normal file
@@ -0,0 +1,10 @@
|
||||
char* strchr(const char* string, int c)
|
||||
{
|
||||
while (*string!='\0')
|
||||
{
|
||||
if (*string==c)
|
||||
return (char*)string;
|
||||
string++;
|
||||
}
|
||||
return (char*)0;
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strcmp.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strcmp.c
Normal file
@@ -0,0 +1,14 @@
|
||||
int strcmp(const char* string1, const char* string2)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (*string1<*string2)
|
||||
return -1;
|
||||
if (*string1>*string2)
|
||||
return 1;
|
||||
if (*string1=='\0')
|
||||
return 0;
|
||||
string1++;
|
||||
string2++;
|
||||
}
|
||||
}
|
4
programs/develop/metcc/trunk/libc/string/strcoll.c
Normal file
4
programs/develop/metcc/trunk/libc/string/strcoll.c
Normal file
@@ -0,0 +1,4 @@
|
||||
int strcoll(const char* string1,const char* string2)
|
||||
{
|
||||
return strcmp(string1,string2);
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strcpy.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strcpy.c
Normal file
@@ -0,0 +1,14 @@
|
||||
char* strcpy(char* strDest,char* strSource)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while(1)
|
||||
{
|
||||
*strDest=*strSource;
|
||||
if (*strSource=='\0')
|
||||
break;
|
||||
strDest++;
|
||||
strSource++;
|
||||
}
|
||||
return res;
|
||||
}
|
17
programs/develop/metcc/trunk/libc/string/strcspn.c
Normal file
17
programs/develop/metcc/trunk/libc/string/strcspn.c
Normal file
@@ -0,0 +1,17 @@
|
||||
int strcspn(const char* string, const char* strCharSet)
|
||||
{
|
||||
const char* temp;
|
||||
int i;
|
||||
i=0;
|
||||
while(1)
|
||||
{
|
||||
temp=strCharSet;
|
||||
while (*temp!='\0')
|
||||
{
|
||||
if (*string==*temp)
|
||||
return i;
|
||||
temp++;
|
||||
}
|
||||
i++;string++;
|
||||
}
|
||||
}
|
9
programs/develop/metcc/trunk/libc/string/strdup.c
Normal file
9
programs/develop/metcc/trunk/libc/string/strdup.c
Normal file
@@ -0,0 +1,9 @@
|
||||
char* strdup(char* str)
|
||||
{
|
||||
char* res;
|
||||
int len;
|
||||
len=strlen(str)+1;
|
||||
res=malloc(len);
|
||||
memcpy(res,str,len);
|
||||
return res;
|
||||
}
|
4
programs/develop/metcc/trunk/libc/string/strerror.c
Normal file
4
programs/develop/metcc/trunk/libc/string/strerror.c
Normal file
@@ -0,0 +1,4 @@
|
||||
char* strerror(int err)
|
||||
{
|
||||
return (char*)0;
|
||||
}
|
11
programs/develop/metcc/trunk/libc/string/strlen.c
Normal file
11
programs/develop/metcc/trunk/libc/string/strlen.c
Normal file
@@ -0,0 +1,11 @@
|
||||
int strlen(const char* string)
|
||||
{
|
||||
int i;
|
||||
i=0;
|
||||
while (*string!='\0')
|
||||
{
|
||||
i++;
|
||||
string++;
|
||||
}
|
||||
return i;
|
||||
}
|
16
programs/develop/metcc/trunk/libc/string/strnbrk.c
Normal file
16
programs/develop/metcc/trunk/libc/string/strnbrk.c
Normal file
@@ -0,0 +1,16 @@
|
||||
char* strpbrk(const char* string, const char* strCharSet)
|
||||
{
|
||||
char* temp;
|
||||
while (*string!='\0')
|
||||
{
|
||||
temp=strCharSet;
|
||||
while (*temp!='\0')
|
||||
{
|
||||
if (*string==*temp)
|
||||
return string;
|
||||
temp++;
|
||||
}
|
||||
string++;
|
||||
}
|
||||
return (char*)0;
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strncat.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strncat.c
Normal file
@@ -0,0 +1,14 @@
|
||||
char* strncat(char* strDest,const char* strSource,int count)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while (*strDest!='\0') strDest++;
|
||||
while (count>0 && *strSource!='\0')
|
||||
{
|
||||
*strDest=*strSource;
|
||||
count--;
|
||||
strDest++;
|
||||
strSource++;
|
||||
}
|
||||
return res;
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strncmp.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strncmp.c
Normal file
@@ -0,0 +1,14 @@
|
||||
int strncmp(const char* string1, const char* string2, int count)
|
||||
{
|
||||
while(count>0)
|
||||
{
|
||||
if (*string1<*string2)
|
||||
return -1;
|
||||
if (*string1>*string2)
|
||||
return 1;
|
||||
if (*string1=='\0')
|
||||
return 0;
|
||||
count--;
|
||||
}
|
||||
return 0;
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strncpy.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strncpy.c
Normal file
@@ -0,0 +1,14 @@
|
||||
char* strncpy(char* strDest,const char* strSource,int count)
|
||||
{
|
||||
char* res;
|
||||
res=strDest;
|
||||
while (count>0)
|
||||
{
|
||||
*strDest=*strSource;
|
||||
if (*strSource!='\0')
|
||||
strSource++;
|
||||
strDest++;
|
||||
count--;
|
||||
}
|
||||
return res;
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strrchr.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strrchr.c
Normal file
@@ -0,0 +1,14 @@
|
||||
char* strrchr(const char* s,int c)
|
||||
{
|
||||
char* res;
|
||||
res=(char*)0;
|
||||
while (1)
|
||||
{
|
||||
if (*s==(char)c)
|
||||
res=(char*)s;
|
||||
if (*s=='\0')
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
return res;
|
||||
}
|
20
programs/develop/metcc/trunk/libc/string/strspn.c
Normal file
20
programs/develop/metcc/trunk/libc/string/strspn.c
Normal file
@@ -0,0 +1,20 @@
|
||||
int strspn(const char* string,const char* strCharSet)
|
||||
{
|
||||
int i;
|
||||
const char* temp;
|
||||
i=0;
|
||||
while (*string!='\0')
|
||||
{
|
||||
temp=strCharSet;
|
||||
while (temp!='\0')
|
||||
{
|
||||
if (*temp==*string)
|
||||
break;
|
||||
}
|
||||
if (temp=='\0')
|
||||
break;
|
||||
*string++;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
13
programs/develop/metcc/trunk/libc/string/strstr.c
Normal file
13
programs/develop/metcc/trunk/libc/string/strstr.c
Normal file
@@ -0,0 +1,13 @@
|
||||
extern int strncmp(char* s1,char* s2,int len);
|
||||
char* strstr(const char* s, const char* find)
|
||||
{
|
||||
int len;
|
||||
len=strlen(find);
|
||||
while (1)
|
||||
{
|
||||
if (strncmp(s,find,len)==0) return s;
|
||||
if (*s=='\0')
|
||||
return (char*) 0;
|
||||
s++;
|
||||
}
|
||||
}
|
14
programs/develop/metcc/trunk/libc/string/strtok.c
Normal file
14
programs/develop/metcc/trunk/libc/string/strtok.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "string.h"
|
||||
char* strtok(char* s,const char* delim)
|
||||
{
|
||||
char* res;
|
||||
if (*s=='\0')
|
||||
return (char*)0;
|
||||
s+=strspn(s,delim);
|
||||
if (*s=='\0')
|
||||
return (char*)0;
|
||||
res=s;
|
||||
s+=strcspn(s,delim);
|
||||
*s=='\0';
|
||||
return res;
|
||||
}
|
4
programs/develop/metcc/trunk/libc/string/strxfrm.c
Normal file
4
programs/develop/metcc/trunk/libc/string/strxfrm.c
Normal file
@@ -0,0 +1,4 @@
|
||||
int strxfrm(char* strDest, const char* strSource, int count)
|
||||
{
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user