#26 options in GBZ80 port not officially documented


Dear SDCC-community,

I know that the GB-Z80 port is unsupported. But does
that mean that its pragmas and compiler options are not
documented in the official SDCC manual and that the
compiler does not show them in the usage information?

There are options/pragmas for ROM and RAM bank
switching which are very helpful for large Gameboy
programs. Also the keywords "banked"
and "nonbanked" flag specific calling conventions.

If there still is some interest in completing the
documentation and the usage help, I am willing to
contribute the appropriate sections.




  • Robert Ramey

    Robert Ramey - 2006-07-24

    Logged In: YES

    I'm very interested in this. Please do this!!!

    Robert Ramey

  • Frieder Ferlemann

    Logged In: YES

    Sorry for the late response. You could attach it
    here (or PM to me).
    If you haven't set up a LyX/LaTeX environment
    then sending a plain text file will be fine too:)

  • Frieder Ferlemann

    Logged In: YES
    Originator: NO

    documentation for the options

    { 0, OPTION_BO, NULL, "<num> use code bank <num>" },
    { 0, OPTION_BA, NULL, "<num> use data bank <num>" },
    { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
    { 0, OPTION_CODE_SEG, &options.code_seg, "<name> use this name for the code segment", CLAT_STRING },
    { 0, OPTION_CONST_SEG, &options.const_seg, "<name> use this name for the const segment", CLAT_STRING },
    { 0, OPTION_NO_STD_CRT0, &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"},

    have made it into the manual (some time since 2006 and now).
    Unfortunately I'm not familiar with the effects/implications
    of "banked" and "nonbanked" on gbz80 so some text would
    be appreciated:)

  • Borut Ražem

    Borut Ražem - 2008-03-12

    Logged In: YES
    Originator: NO

    It seems that "banked" and "nonbanked" are avaliable on both gbz80 and z80.

    Maybe Philipp Klaus Krause can help us?


  • Philipp Klaus Krause

    Logged In: YES
    Originator: NO

    The Z80 supports the use of a 16 bit I/O address space; it's not stated very prominently, but it's an official, documented Z80 feature.

    The "banked" keyword is used in sdcc to use the 16 bit I/O address space instead of the 8 bit one.

    AFAIK there is no support for ROM or RAM banking in the Z80 port.


  • Borut Ražem

    Borut Ražem - 2008-03-13

    Logged In: YES
    Originator: NO

    I found out that the "banked" keyword is documented in chapter 3.4.2 "Z80/Z180 Storage Class Language Extensions". Sgould we rename it to "GBZ80/Z80/Z180 Storage Class Language Extensions"?


  • Maarten Brock

    Maarten Brock - 2008-03-13

    Logged In: YES
    Originator: NO

    No, I don't think so. The GBZ80 does not have any IO-space. It is strictly vonNeumann.

    So the only thing still missing is some text about bank switching on the GBZ80, right?

  • Peter Townson

    Peter Townson - 2008-03-14

    Logged In: YES
    Originator: NO

    This is just a quick note to clarify and confirm that banked/nonbanked support for the gbz80 is very definately separate from that implemented for the Z80/Z180.

    As I recall the GameBoy hardware allowed for multiple banks of memory in the higher address ranges (somewhere arround the 0xC000 mark as I recall) the need to be able to specify the 'banked' or 'nonbanked' nature of storage (variables, functions, etc). (I have always intended to have a play with this - just havent got there yet)

    The Z80/Z180 'banked' usage is purely used as a modifier for the 'sfr' keyword for determining the type of addressing used to access 'port' space - defining an sfr as banked results in the 16 bit addressing mode (which exploits a documented but not originally publicized behaviour of the CPU internals), as opposed to the normal 8 bit addressing mode.

    I hope I'm not boring people by reiterating what everybody knows...

    PeterT :->

  • Philipp Klaus Krause

    Hmm, I've taken a quick look at this. I might have missed something, but to me the situation looks like this:
    __banked for functions works as for all ports where it is not really implemented: A call to function g becomes

    call banked_call
    .dw _g
    .dw 0 ; PENDING: bank support

    if g is banked instead of cul

    call _g

    Using #pragma bank 12
    results in an area named _CODE_12 used for the code segment (i.e. the integer specified in teh pragma is appended to the name of the code segment.

    I do not know how useful all this is. It looks incomplete to me, which might be the reason it is undocumented.



Log in to post a comment.