Non-constant constant strings

Discussion in 'C Programming' started by Rick C. Hodgin, Jan 19, 2014.

  1. Seebs of course makes a good point. My point was that even in C++,
    you can't overload an operator for a built-in type that already
    has that operator. You can't write your own

    double operator+(double, double);

    that will be invoked when you add two double values.

    And even if addition for some type is implemented as a function
    call, its semantics are still defined by the standard's rules for
    operators, not by the rules for function calls.
    I would be unsurprised if the saving and restoring of the registers
    were done with inline code rather than function calls. But I'm
    not familiar with the Z80, and perhaps a function call saves enough
    code size to make it worthwhile.
     
    Keith Thompson, Feb 22, 2014
    1. Advertisements

  2. Rick C. Hodgin

    David Brown Guest

    I haven't used a Z80 C compiler for 30 years, but in general (for small
    cpus) it is hard to make "save volatile registers" into a function call
    because the registers are usually saved on the same stack as the return
    address. The extra stack manipulation needed to make it work means it
    is seldom worth the effort. "restore volatile registers" is easier,
    because the epilogue of normal functions will often be a sequence of
    register "pops" to restore the volatile registers, followed by a
    "return". You can then have a single common copy of this, and replace
    the epilogues of normal functions with a "jump" into the appropriate
    point of this sequence.

    Some compiler/cpu combinations have separate data and return stacks,
    which let you make the save/restore sequences be function calls. The
    Imagecraft AVR compiler is one example that used this to save space (the
    AVR has 32 registers, but no multi-register save or restore, so big
    functions require saving and restoring a lot of registers individually).
     
    David Brown, Feb 24, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.