/programs/develop/ktcc/trunk/libc/gcc compile programs/README.txt |
---|
0,0 → 1,3 |
 ýòîì êàòàëîãå ñîäåðæèòñÿ 2 ôàéëà, íåîáõîäèìûõ äëÿ ñáîðêè ïðîãðàìì äëÿ KolibriOS ïðè ïîìîùè gcc. |
In this catalogue contains 2 files necessary for assembly of programs for KolibriOS with the help gcc. |
/programs/develop/ktcc/trunk/libc/gcc compile programs/makefile |
---|
0,0 → 1,22 |
OUTFILE = test.kex |
INPUT = test.c |
OUTPUT = test.o |
OBJS = start.o test.o |
.SUFFIXES: .asm .o |
$(OUTFILE) : $(OBJS) |
fasm start.asm start.o |
gcc -c $(INPUT) -nostdinc -m32 -I/home/andrew/kolibri/develop/include/ |
ld -nostdlib -T kolibri.ld -n -m elf_i386 -L/home/andrew/kolibri/develop/lib/ -o $(OUTFILE) $(OBJS) -lck |
objcopy $(OUTFILE) -O binary |
.asm.o: |
fasm $*.asm |
.c.o: |
gcc -c $*.c |
clean : |
del *.o |
/programs/develop/ktcc/trunk/libc/gcc compile programs/start.asm |
---|
0,0 → 1,102 |
format ELF |
section '.text' executable |
public start_ |
extrn main |
buf_len = 0x400 |
max_parameters=0x20 |
start_: |
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 params ; 7. Pointer to program arguments |
hpath dd path ; 8. Pointer to program path |
start__: |
;init heap of memory |
mov eax,68 |
mov ebx,11 |
int 0x40 |
mov ebx,path |
mov ecx,dword buf_len |
add ebx,ecx |
next_simbol_check: |
xor eax,eax |
mov al,[ebx] |
cmp al,'/' |
je simbol_fined |
dec ebx |
dec ecx |
jnz next_simbol_check |
simbol_fined: |
inc ebx |
mov [argc],dword 1 |
mov edx,argv |
mov [edx],ebx ;argument number 0 - program name |
cmp [params],byte 0 |
je exit_find_params |
mov [argc],dword 2 |
mov ebx,params |
add edx,4 |
mov [edx],ebx |
next_symbol_parse: |
xor eax,eax |
mov al,[ebx] |
test al,al |
jz exit_find_params |
cmp al,' ' |
je save_param |
inc ebx |
jmp next_symbol_parse |
save_param: |
mov [ebx],byte 0 |
inc ebx |
add edx,4 |
mov [edx],ebx |
inc [argc] |
cmp [argc],max_parameters |
jae exit_find_params |
jmp next_symbol_parse |
exit_find_params: |
push argv |
push [argc] |
call main |
exit: |
xor eax,eax |
dec eax |
int 0x40 |
dd -1 |
crash: |
jmp exit |
public params as '__argv' |
public path as '__path' |
section '.bss' |
argc rd 1 |
argv rd max_parameters |
path rb buf_len |
params rb buf_len |
/programs/develop/ktcc/trunk/libc/include/stdlib.h |
---|
2,6 → 2,8 |
#define stdlib_h |
#include "kolibrisys.h" |
#define RAND_MAX 65535 |
//#define isspace(c) ((c)==' ') |
#define abs(i) (((i)<0)?(-(i)):(i)) |
15,4 → 17,8 |
extern void* stdcall malloc(dword size); |
extern void stdcall free(void *pointer); |
extern void* stdcall realloc(void* pointer,dword size); |
extern int rand (void); |
extern void srand (unsigned int seed); |
#endif |
/programs/develop/ktcc/trunk/libc/kolibrisys/sound.asm |
---|
1,7 → 1,7 |
format ELF |
include "public_stdcall.inc" |
section '.text' executable |
public_stdcall _ksy_sound_load_block,4 |
public_stdcall _ksys_sound_load_block,4 |
;arg1 - blockptr |
mov edx,ebx |
mov eax,55 |
11,7 → 11,7 |
mov ebx,edx |
ret 4 |
public_stdcall _ksy_sound_play_block,0 |
public_stdcall _ksys_sound_play_block,0 |
mov edx,ebx |
mov eax,55 |
xor ebx,ebx |
20,7 → 20,7 |
mov ebx,edx |
ret |
public_stdcall _ksy_sound_set_channels,4 |
public_stdcall _ksys_sound_set_channels,4 |
;arg1 - channels |
push ebx |
mov eax,55 |
31,7 → 31,7 |
pop ebx |
ret 4 |
public_stdcall _ksy_sound_set_data_size,4 |
public_stdcall _ksys_sound_set_data_size,4 |
;arg1 - data size |
push ebx |
mov eax,55 |
43,7 → 43,7 |
pop ebx |
ret 4 |
public_stdcall _ksy_sound_set_frequency,4 |
public_stdcall _ksys_sound_set_frequency,4 |
;arg1 - frequency |
push ebx |
mov eax,55 |
54,12 → 54,12 |
pop ebx |
ret 4 |
public_stdcall _ksy_sound_speaker_play,4 |
public_stdcall _ksys_sound_speaker_play,4 |
;arg1 - data |
mov edx,ebx |
mov eax,55 |
mov ebx,55 |
mov ecx,[esp+4] |
mov esi,[esp+4] |
int 0x40 |
mov ebx,edx |
ret 4 |
ret 4 |
/programs/develop/ktcc/trunk/libc/makefile |
---|
2,7 → 2,7 |
LIBSFORBUILD = math |
LIBNAME = libck.a |
CC = gcc |
CFLAGS = -I$(INCLUDE) -nostdinc -DGNUC -L./ -lm |
CFLAGS = -I$(INCLUDE) -m32 -nostdinc -nostdlib -DGNUC |
DIRS := stdio kolibrisys string stdlib memory math |
############################################################## |
/programs/develop/ktcc/trunk/libc/math/ceil.asm |
---|
0,0 → 1,30 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public ceil |
ceil: |
push ebp |
mov ebp,esp |
sub esp,8 |
fstcw [ebp-12] |
mov dx,[ebp-12] |
or dx,0x0800 |
and dx,0xfbff |
mov word[ebp-16],dx |
fldcw [ebp-16] |
fld qword[ebp+8] |
frndint |
fldcw [ebp-12] |
leave |
ret |
/programs/develop/ktcc/trunk/libc/math/ceilf.asm |
---|
0,0 → 1,30 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public ceilf |
ceilf: |
push ebp |
mov ebp,esp |
sub esp,8 |
fstcw [ebp-12] |
mov dx,[ebp-12] |
or dx,0x0800 |
and dx,0xfbff |
mov word[ebp-16],dx |
fldcw [ebp-16] |
fld dword[ebp+8] |
frndint |
fldcw [ebp-12] |
leave |
ret |
/programs/develop/ktcc/trunk/libc/math/fabs.asm |
---|
0,0 → 1,14 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public fabs_ as "fabs" |
fabs_: |
fld qword[esp+4] |
fabs |
ret |
/programs/develop/ktcc/trunk/libc/math/fabsf.asm |
---|
0,0 → 1,14 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public fabsf |
fabsf: |
fld dword[esp+4] |
fabs |
ret |
/programs/develop/ktcc/trunk/libc/math/floor.asm |
---|
0,0 → 1,29 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public floor |
floor: |
push ebp |
mov ebp,esp |
sub esp,8 |
fstcw [ebp-12] |
mov dx,word[ebp-12] |
or dx,0x0400 |
and dx,0xf7ff |
mov word[ebp-16],dx |
fldcw [ebp-16] |
fld qword[ebp+8] |
frndint |
fldcw [ebp-12] |
leave |
ret |
/programs/develop/ktcc/trunk/libc/math/floorf.asm |
---|
0,0 → 1,29 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public floorf |
floorf: |
push ebp |
mov ebp,esp |
sub esp,8 |
fstcw [ebp-12] |
mov dx,word[ebp-12] |
or dx,0x0400 |
and dx,0xf7ff |
mov word[ebp-16],dx |
fldcw [ebp-16] |
fld dword[ebp+8] |
frndint |
fldcw [ebp-12] |
leave |
ret |
/programs/develop/ktcc/trunk/libc/math/sqrt.asm |
---|
0,0 → 1,14 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public sqrt |
sqrt: |
fld qword[esp+4] |
fsqrt |
ret |
/programs/develop/ktcc/trunk/libc/math/sqrtf.asm |
---|
0,0 → 1,14 |
format ELF |
include 'proc32.inc' |
section '.text' executable |
public sqrtf |
sqrtf: |
fld dword[esp+4] |
fsqrt |
ret |
/programs/develop/ktcc/trunk/libc/stdlib/random.c |
---|
0,0 → 1,15 |
#include "stdlib.h" |
unsigned int seed_o=1; |
void srand (unsigned int seed) |
{ |
seed_o=seed; |
} |
int rand (void) |
{ |
seed_o=(seed_o*25173+13849) & (65535); |
return(seed_o); |
} |