New CLIB Looking for Testers
Posted: Mon Dec 22, 2014 7:58 am
There have been some substantial changes within z88dk over the past year.
Among them are:
* zcc has been modified to allow C compilation by either sccz80 or sdcc
* z80asm has been modified to introduce sections
* new clib has been committed that aims to implement a large subset of C11
The existing clib has also been growing but the aim of this sub-board is to test the new clib in combination with the new features in z80asm.
The new clib has been written from scratch, with only a small number of functions surviving unchanged from the existing clib. The number of functions is more than 400 consisting of somewhere around 25,000 lines of asm code. There is a lot of potential for errors in there and it is hoped that some user testing prior to release will help stamp out the most egregious ones. The forum was created because a few people did volunteer to help with some testing but anyone at large is welcome to help.
The main goals of the new clib:
* Implement as large a subset of the C11 standard as is reasonable on an 8-bit uP.
* Be the fastest and smallest z80 library among libraries with the most capability.
* Separate implementation from the C interface so that the library is easily used in assembler projects and with any z80 C compiler.
* Make use of the new sections feature of z80asm, the underlying linking assembler in z88dk. Sections permit the automatic generation of ROMable code and targetting of bankswitched memory systems.
* The entire library must be re-entrant to support the multithreading features demanded in C11.
* The library must be highly configurable at library build time and at compile time. This will allow the user to choose between fast or small implementations of library code and to choose among options for memory model and size of clib data structures from within C source.
* Supply an object oriented driver model that allows new targets to quickly gain access to tty-emulated input and output terminals as well as disk drivers.
* Support any number of attached devices and assign them to a global namespace.
* Portable to any z80 platform.
* Make the distinction between C for "big" machines and C for "small" machines disappear.
The new clib is still growing but the core is present and that is what we are looking to test. Here is an overview of current functionality:
* adt (Abstract Data Types) - a collection of container types modelled on C++ STL containers. Things like arrays, vectors, linked lists, priority queues, stacks and queues are present. The same api as in C++ is used.
* alloc (Dynamic Memory Allocation) - balloc (a block memory allocator), malloc (a heap allocator) and obstack (GNU's object stack allocator) are present. The malloc and obstack modules can manage any number of independent heaps/obstacks through a named heap/obstack api. This means, for example, you could have different heaps for different banking configurations. The malloc library is especially rich with aligned allocation present and realloc especially optimized to be fast as the C11 standard relies on it so much.
* compress - contains the tiny lz77 data decompressor written by Einar Saukas. This decompressor is also used by the crt to decompress the data segment into ram on startup when programs are compiled for the rom model.
* fcntl - posix subset and file descriptors. Drivers are object oriented and this subdirectory also contains abstract classes for easily implementing fully functional input and output terminals. An object oriented disk stack is also on the way.
* font - fzx by Andrew Owen and Einar Saukas is a proportional font printing system for 8-bit micros. Close to 100 fonts are available. I am currently rewriting this to be re-entrant so that it can be used in output terminals.
* math - the integer math library with options for choosing between small and fast versions. The fast version has further options for selecting things like loop unrolling and leading zero elimination. Floating point math has not been added yet! There is a z80 implementation in the existing z88dk clib that has not been migrated so if you need this, just ask and we can push up the priority.
* sound - currently contains 1-bit sound generators. Any system with a memory mapped or port-mapped speaker with on/off bit is supported. Sounds range from simple beeps to sound effects to polyphonic to a 3-voice synthesizer with drums. I did attempt to insert fast clock compensation for fast z80s but that will have to wait until z80asm gains a macro feature.
* stdio - just about everything you can think of. stdio can attach high level FILE i/o to any device that can be opened on a file descriptor. Memory streams are also supported, allowing FILE i/o to operate on a vector<char> in memory. It is planned to extend this scheme to bankswitched systems so that one way to access more than 64k will be treating the extra memory as a memstream.
* stdlib - most functions are present. qsort can be configured to use insertion sort, shellsort or quicksort. Quicksort can be configured to use middle item or random item as pivot and has options to use insertion sort for small partitions, randomize assignment to left or right intervals for equal items, etc.
* strings - all string functions are present plus many from bsd and gnu.
* z80 - processor related functions like precise delays measured in milliseconds or T states, a comprehensive im2 api, and access to i/o from C.
Testing functionality is a decidedly unsexy task. We're not expecting anyone to go so far as design unit tests but mainly to try things out from a user-level to root out the most egregious bugs. If your test programs can be used as examples, we can perhaps immortalize your efforts by including them in an examples directory.
Among them are:
* zcc has been modified to allow C compilation by either sccz80 or sdcc
* z80asm has been modified to introduce sections
* new clib has been committed that aims to implement a large subset of C11
The existing clib has also been growing but the aim of this sub-board is to test the new clib in combination with the new features in z80asm.
The new clib has been written from scratch, with only a small number of functions surviving unchanged from the existing clib. The number of functions is more than 400 consisting of somewhere around 25,000 lines of asm code. There is a lot of potential for errors in there and it is hoped that some user testing prior to release will help stamp out the most egregious ones. The forum was created because a few people did volunteer to help with some testing but anyone at large is welcome to help.
The main goals of the new clib:
* Implement as large a subset of the C11 standard as is reasonable on an 8-bit uP.
* Be the fastest and smallest z80 library among libraries with the most capability.
* Separate implementation from the C interface so that the library is easily used in assembler projects and with any z80 C compiler.
* Make use of the new sections feature of z80asm, the underlying linking assembler in z88dk. Sections permit the automatic generation of ROMable code and targetting of bankswitched memory systems.
* The entire library must be re-entrant to support the multithreading features demanded in C11.
* The library must be highly configurable at library build time and at compile time. This will allow the user to choose between fast or small implementations of library code and to choose among options for memory model and size of clib data structures from within C source.
* Supply an object oriented driver model that allows new targets to quickly gain access to tty-emulated input and output terminals as well as disk drivers.
* Support any number of attached devices and assign them to a global namespace.
* Portable to any z80 platform.
* Make the distinction between C for "big" machines and C for "small" machines disappear.
The new clib is still growing but the core is present and that is what we are looking to test. Here is an overview of current functionality:
* adt (Abstract Data Types) - a collection of container types modelled on C++ STL containers. Things like arrays, vectors, linked lists, priority queues, stacks and queues are present. The same api as in C++ is used.
* alloc (Dynamic Memory Allocation) - balloc (a block memory allocator), malloc (a heap allocator) and obstack (GNU's object stack allocator) are present. The malloc and obstack modules can manage any number of independent heaps/obstacks through a named heap/obstack api. This means, for example, you could have different heaps for different banking configurations. The malloc library is especially rich with aligned allocation present and realloc especially optimized to be fast as the C11 standard relies on it so much.
* compress - contains the tiny lz77 data decompressor written by Einar Saukas. This decompressor is also used by the crt to decompress the data segment into ram on startup when programs are compiled for the rom model.
* fcntl - posix subset and file descriptors. Drivers are object oriented and this subdirectory also contains abstract classes for easily implementing fully functional input and output terminals. An object oriented disk stack is also on the way.
* font - fzx by Andrew Owen and Einar Saukas is a proportional font printing system for 8-bit micros. Close to 100 fonts are available. I am currently rewriting this to be re-entrant so that it can be used in output terminals.
* math - the integer math library with options for choosing between small and fast versions. The fast version has further options for selecting things like loop unrolling and leading zero elimination. Floating point math has not been added yet! There is a z80 implementation in the existing z88dk clib that has not been migrated so if you need this, just ask and we can push up the priority.
* sound - currently contains 1-bit sound generators. Any system with a memory mapped or port-mapped speaker with on/off bit is supported. Sounds range from simple beeps to sound effects to polyphonic to a 3-voice synthesizer with drums. I did attempt to insert fast clock compensation for fast z80s but that will have to wait until z80asm gains a macro feature.
* stdio - just about everything you can think of. stdio can attach high level FILE i/o to any device that can be opened on a file descriptor. Memory streams are also supported, allowing FILE i/o to operate on a vector<char> in memory. It is planned to extend this scheme to bankswitched systems so that one way to access more than 64k will be treating the extra memory as a memstream.
* stdlib - most functions are present. qsort can be configured to use insertion sort, shellsort or quicksort. Quicksort can be configured to use middle item or random item as pivot and has options to use insertion sort for small partitions, randomize assignment to left or right intervals for equal items, etc.
* strings - all string functions are present plus many from bsd and gnu.
* z80 - processor related functions like precise delays measured in milliseconds or T states, a comprehensive im2 api, and access to i/o from C.
Testing functionality is a decidedly unsexy task. We're not expecting anyone to go so far as design unit tests but mainly to try things out from a user-level to root out the most egregious bugs. If your test programs can be used as examples, we can perhaps immortalize your efforts by including them in an examples directory.