I keep coming back to this in my head.
I think we can probably do something here that鈥檚 not too intrusive. Ideally the 8080 abi would be bcde rather than dehl but that鈥檚 a large change.
The main target would be cpm of course.
Another 8008 and 8080 32-bit math option could be built too, the Lawrence Livermore (National) Labs Floating Point Library, circa 1973.
Integrating this library into z88dk is on my list (admittedly sidelined until we have 32-bit math support in newlib), because of its commonality with Am9511A. I'm not 100% certain, but I'd guess that the Am9511A was built to replicate the LLL floating point format.
I had a look at that last night - I couldn鈥檛 see the trig functions - did I miss them?
No. You didn't miss them.
There's nothing except the 4 arithmetic functions, and some helper functions to convert fixed to float and back, in the library. Pretty basic. But probably used to design ICBM flight paths, amongst other things.
This is the original 8080 code, before conversion to Zilog mnemonics, from Herb's stuff.
This is a little bit of an ordeal but the basics are almost there.
Long support is currently broken, stdlib has mostly gone missing along with all the algorithm and allocation libraries - hopefully I can get the regular malloc back in.
The old c based printf (mini version) has reappeared - writing printf in assembler once is enough for me - so bits of the test suite are now working.
Quite obvious, but it is too funny to resist !
This one is tested:
._ldir
push af
.ldir_loop
ld a,(hl)
ld (de),a
inc hl
inc de
dec bc
ld a,b
or c
jr nz,ldir_loop
pop af
(ret)
It is 11 bytes long, probably it is worth to keep it as a subroutine and save space.
For a better emulation, the flags after the LDI/LDD instructions should be altered as follows:
S - Sign
Z - Zero flag
F5 - undocumented flag
H - Half Carry
F3 - undocumented flag
P/V - Parity or Overflow
N - Subtract
C - Carry
SZ5H3VNC
--*0**0-
PV set if BC not 0
F5 is bit 1 of (transferred byte + A)
F3 is bit 3 of (transferred byte + A)
EDIT: the only useful flag in my opinion is P/V when checked after LDI or LDD, but I think we can live without it.
@zx70 yes, I did some magic in z80asm to handle mapping:
The jumps work well as long as they don't reference ASMPC, and the emulation is the same as we did for the Rabbit. So there's an ldir implementation here: https://github.com/z88dk/z88dk/blob/feature/8080/src/z80asm/dev/z80asm_lib/ldir.asm
Comment to indicate the things that have been removed so I can document them later:
SDCC support
The only critical feature removed is number conversion routines. I'll see if I can resurrect some versions from the grave/adapt the newlib ones without too much pain.
This also opens up the idea of 8085 support. Some of the undocumented opcodes look interesting:
SHLX is basically l_pint for example. Information here: http://electronicerror.blogspot.com/2007/08/undocumented-flags-and-instructions.html
That's a cute one. I'd really like to try to add support for the Kyocera family handheld computers (aka Tandy 100/200)
Yeah, I think this and any 8085 enhancements will open an entire new tranche of targets. Getting to 100 z80 targets feels like it's a long way off.
we are totally crazy :D
Let鈥檚 call this one done for now.
Ken Yap (the very first version of z88dk was based off his zcc096.zip package), has a wip 8080 port of sdcc in this repo: https://github.com/kenyapcomau/sdcc-8080