Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9557 → Rev 9558

/programs/develop/ktcc/trunk/lib/sample/sample_symbol.asm
0,0 → 1,18
format ELF
 
include "__lib__.inc"
 
fun equ sample_symbol
fun_str equ 'sample_symbol'
 
section '.text'
 
fun_name db fun_str, 0
 
section '.data'
 
extrn lib_name
public fun
 
fun dd fun_name
lib dd lib_name
/programs/develop/ktcc/trunk/lib/sample/__lib__.asm
0,0 → 1,9
format ELF
 
include '__lib__.inc'
 
section '.text'
 
public lib_name
 
lib_name db 0x55, 0xAA, lib_name_str, 0
/programs/develop/ktcc/trunk/lib/sample/__lib__.inc
0,0 → 1,2
lib_name equ @sample.obj
lib_name_str equ '/sys/lib/sample.obj'
/programs/develop/ktcc/trunk/lib/sample/howto.txt
0,0 → 1,13
Create new library wrapper
 
1. Redefine lib_name and lib_name_str in __lib__.inc
2. Create file for each symbol, basing on sample_symbol.asm and for each:
2.1. Redefine fun to *your_symbol_name*
2.2. Redefine fun_name to '*your_symbol_name*' (with quotes, this is ASCII string, no trailing zero need)
3. Change make.bat as appropriate
 
ACHTUNG: lib_name need to be unique in project, this is why I started it with "@" and put "." into.
ACHTUNG: lib_name_str must be at least 5 symbols long, if is not, fix this adding padding to the path.
 
Now you can create header file and declare extern variables pointers-to-functions, and then link your app with -llibname (put .a file in lib folder).
For examples of such header files, look at include/kos/inputbox.h, include/kos/console.h and include/kos/http.h. IMO, first one is the simplest.
/programs/develop/ktcc/trunk/lib/sample/make.bat
0,0 → 1,5
fasm __lib__.asm
fasm sample_symbol.asm
kos32-ar -ru libsample.a *.o
del *.o
pause