6th (Final) Update – 26th October
Rework of z88dk classic 8080/8085/gbz80 library functions.
When working with the 8085, the biggest issue is the continual pressure on the few CPU registers. The 8-bit accumulator
a register and the 16-bit accumulator
hl registers have only two additional pairs that can be used, the
de registers. This gives the system programmer few options but to use (static) memory locations to store intermediate values, leading to non-reentrant code.
Having non-reentrant code is normally not a problem, but it leads to issues when multiple threads (or tasks) are trying to use the CPU at the same time. So it is useful to try to build reentrant functions that use the stack for storage of intermediate values, rather than static locations.
The designers of the 8085 had this in mind when they designed the additional functions found the 8085 silicon. The “new” instructions make it very efficient to build stack relative functions (compared to the 8080), and this relieves some pressure on the small number of registers.
However, there was one oversight made by the designers, as the 8085
af register pair cannot be used, as with the z80, to
push words from the stack. This reduces the number of available 16-bit registers by 1 of possible 4. There is one flag bit that always reads as 0, which is an subtle but annoying limitation in the 8085.
For the past two weeks I’ve been working on a refresh of all of the integer and long basic compiler (
l_) functions to try to make them reentrant and, where possible, to optimise them for the 8085 CPU. I’ve also moved the improvements to the 8080 CPU and Gameboy Z80 CPU where possible too.
As background, some of these functions originate from the 1980s and 1990s in the Amsterdam Compiler Kit, and haven’t been updated or improved for the past 20 years. They weren’t broken. But they were in need of some reentrant attention.
So this update is the final and biggest one in the October 2021 RetroChallenge. All the new functions are checked in and are now part of the z88dk.