xyzzy

tinylibs.zip

Content

tinylibs.html     : this file
tiny.nmk          : MS C 6.0 nmake file
src\crtiny.asm    : DOS 2.x/3.x specific init/term
src\tinymsg.asm   : DOS 2.x/3.x error messages
src\tmalloc.asm   : tiny malloc (heap within stack)
src\tinyseg.asm   : tiny _growseg(), optional object
src\tinycpyr.c    : "manual", inserts copyright string in tiny binaries
src\nulbody.c     : test program returning 0 after doing nothing
src\nulinit.c     : dito without _nullcheck(), _setenvp(), _setargv()
src\nulreal.c     : test SIGFPE handler without floating point support
src\nulbased.c    : _based segment test _bheapseg() and _bmalloc()
src\tinytest.c    : test derived from rxfiles.zip
src\minitest.c    : dito without near heap
bin\crtiny.lib    : tiny *.COM startup library with near heap in stack
bin\crtinye.lib   : dito *.EXE (CS = DS = SS = DGROUP)
bin\crtini.lib    : dito *.COM startup library without (!) near heap
bin\crtinie.lib   : dito *.EXE (CS = DS = SS = DGROUP)
bin\tinyseg.obj   : only needed with _based segments replacing _growseg()
bin\*.lrf         : linker rersponse files used to create the libraries
bin\*.com         : 5 tiny test programs + 4 normal msc*.com programs
bin\*.exe         : 7 tiny test programs + 3 normal msc*.exe programs

Description (src\tinycpyr.c)

tiny MS C 6.0 startup libraries, copyright (c) 1997, Frank Ellermann

crtiny.lib and crtinye.lib replace the MSC 6.0 near heap malloc
above stack, i.e. allocate heap space at bottom of stack. This
may be handy in TSRs, but its main pupose is to simplify malloc
itself.

CRT startup uses malloc() in _setenvp(), unless this is disabled
by a stub function doing nothing. Many other C library functions
use malloc(), including setargv.obj. Whenever you cannot avoid
to use malloc() completely (see link /MAP), then crtiny.lib or
crtinye.lib are smaller than the original MSC 6.0 C startup.

crtini.lib and crtinie.lib provide no near heap at all. This is
useful in special programs like TSRa, which can avoid _nmalloc()
completely. In crtini.lib and crtinie.lib _setenvp() is disabled
by default.

All above mentioned libraries have in common, that they stub out
_fileinfo, this is also the default in MSC 6.0 CRT startup. You
cannot overwrite _fileinfo == 0 by fileinfo.obj. Do not change
this value dynamically in your program. A variant of _cenvarg()
not referencing _fileinfo and _acfinfo should be developped.

All four above mentioned libraries avoid null pointer assignment
tests at exit. You don't need to stub out _nullcheck(), because
it's not called. MSC 6.0 CRT startup does not call _nullcheck()
for tiny model *.COM too.

There is no more overlay interrupt support in these 4 libraries.
Quick C debugger support has been removed, don't use option -Zr.
There is yet NO (!) floating point support in these 4 libraries.

Unlike the original MSC 6.0 CRT startup SIGFPE (corresponding to
INT 0 integer divide exeception) is fully supported. The default
handler displays a R6003 runtime error and calls exit(), you can
replace it easily using signal( SIGFPE ). This is not compatible
with the normal MSC 6.0 behaviour, which doesn't support SIGFPE
in programs without floating point access.

Only /AT tiny and /AS small models are supported, don't try to
use these libraries for other models. Even in small model code
is added to DGROUP, this simplifies the customized CRT startup,
but restricts code and data to 64 KB together (including stack).

With its near heap as lower part of the stack a tiny *.EXE does
not need link option CPARMAX and restricts its size in startup
to minimum (_end + STACK). The MSC 6.0 startup keeps full 64 KB
for *.COM files (for maximal near heap growth). Both crtin?.lib
shrink their segment to _end + _stacksize (or 3276) for a *.COM
file at startup.

Both crtiny.lib and crtinye.lib use customized functions for the
near heap management including a dummy _amblksiz. This variable
is normally contained in growseg.asm, a big and for tiny useless
library module. If you need based heap functions like _bmalloc()
in your tiny program, you'll get a link conflict with _amblksiz:
Link your program with tinyseg.obj (replacing growseg.asm) in
this special case.

Example for the creation of *.EXE files using crtin?e.lib, note
that you must specify a stack size, because there is no default:

cl -AS -W4 -FoMAIN.OBJ -c MAIN.C
link /NOI/NOE/NON /STACK:0x800 crtinye.lib MAIN.OBJ,MAIN.EXE;

Example for the creation of *.COM files using crtin?.lib:

cl -AS -W4 -FoMAIN.OBJ -c MAIN.C
link /NOI/NOE/TIN crtiny.lib MAIN.OBJ,MAIN.COM;

Example for a crtiny *.COM using based (or far) heap functions:

cl -AS -W4 -FoMAIN.OBJ -c MAIN.C
link /NOI/NOE/TIN crtiny.lib MAIN.OBJ tinyseg.obj,MAIN.COM;

The default stack size for *.COM files is 3276. If you need more
or less stack set unsigned const _stacksize = ???? in your main
module.


TODO: special add-on object module (like tinyseg.obj, see above)
to load floating point support (?). Requires at least a separate
cdata segment (and an emulator code segment ?)

TODO: variant of crtinye.lib for *.EXE with CS != DS, i.e. 64 KB
code _plus_ 64 KB DGROUP including near heap, stack, and _BSS.

TODO: _expand(), i.e. _nexpand, would pull in _growseg() again,
unnecessary or even incorrect because of reset _HEAP_MODIFY bit
for a tiny heap. Need a simplified _nexpand() for tiny heap !?

TODO: _heapmin() in tmalloc.asm could really do something with a
tiny heap, i.e. return free last block to stack. Could be done
in another add-on object like tinyseg.obj including _nexpand() ?
For now there are only stubs in tmalloc.asm simply returning 0.

XHTML validator Last update: 21 Mar 2002 10:20 by F.Ellermann