Menu

Help with Z80 embedded projects, memory mapping, int,

2016-08-10
2016-08-10
  • Eric Stringer

    Eric Stringer - 2016-08-10

    In building my Z-80 board and using sdcc I see a lot of the same questions pop up, but hard to find answers.
    My hope is that mabye I can get all these answers so that future builders will be able to find them easy.

    After a lot of searching found a trick to get sdcc to compile a working program, that I can upload into the system and run.

    sdcc -mz80 --code-loc 0x0200 --data-loc 0x000 --no-std-crt0 simz80crt0.rel Z80_IRQ.rel z80pio.c

    Only change made from the standard crt0 is top of stack location, for intital builds.

    Like a lot of people I am developing my Z-80 using RAM inplace of a EPROM for intital testing the development, final code would be burned into a eprom or other non-volatile storage. I have a second RAM chip for system varible and data storage, stack etc.

    One issue is I use a hextobin to convert the output of sdcc binary file in which I load to ram, when I set the data-loc for bottom of RAM space this creates a binary file the size of lower EPROM + into RAM space. Since I running the test program in RAM, I can compile with the data-loc set to zero and it set's varibles just after program space(smaller file to load) . Which works for now, but is there a way to create memory map or something to point to RAM area or maybe tips on memory handling.

    Also I'd like to create a group of generic libraries for the Z-80 some in the way Arduino ones work when progamming it. Or is there some already out there?

    I have success in testing out on the basic interrupt handling with the sdcc (fixed locations in lower memory space), the other is using the Z-80's non fixed and createing interupt table location on the fly at compile time as to have a skeleton interrupt program that could be used to work with Z80 PIO, CTC, SIO.

     
  • alvin

    alvin - 2016-08-10

    Have a look at z88dk:
    http://www.z88dk.org/wiki/doku.php?id=libnew:target_embedded

    Its C library is written in assembly language and is much more complete than sdcc's. It uses a patched version of sdcc which generates smaller code than sdcc as well (use --opt-code-size to get even smaller code, particularly if the programs uses many longlong, long or float). The combination of sdcc and z88dk gives you strong standards compliance.

    As you can see from the above link, you can easily customize the embedded environment including using RAM or ROM model compiles. The toolchain is built on z88dk's backend, not sdcc's, so a small change is any assembly should be in standard Zilog form.

    To use the features listed there you must use a nightly build:
    http://www.z88dk.org/wiki/doku.php?id=temp:front#installation
    http://www.z88dk.org/wiki/doku.php?id=temp:front#sdcc1

    The z88dk site is going down for maintenance this evening and/or thursday so the wikis above will be unavailable during that time.

     

Log in to post a comment.