1. Vagner Franco Pereira

    Thread Starter New Member

    Feb 10, 2015
    2
    0
    i want to migrate a z80 code writing in C and asm to arm platform with linux. But in the old z80 code has some type qualifiers that gcc don't recognize. The qualifiers are basenear and code. Can anyone explain to me what they do?
    Examples :
    static code char m_default[] ={ " DEFAULT "};
    basenear char tx_c1(char *, char);{...}
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    These are only educated guesses, but
    "static code" is like a global variable with file scope allocated in "code" space as defined by a memory management unit or other schema.

    "basenear" refers to a variable allocated by means of a base register within some (small) number of addresses, like 64K. Again it probably refers to a memory management version o the Z80.
     
  3. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,675
    2,724
    Funny, "basenear" does not come up on a Google search *at all*.

    Oh, and 64K is not "small" wrt to Z80. That represents the entire address range.
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,431
    3,360
    Why not just delete basenear and static code?

    Let the compiler assign it to SRAM.
     
  5. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    IIRC, Aztec C and 2500AD both had provisions for quick access by using the Z80's ability to index off a register pair making it a one byte instruction. I don't recall the exact syntax but basenear sounds like it's something like that.

    I do recall that specifying a variable as code const told the linker to put the data in the code segment where the ROM (presumably) was. Z80's data and program memory were addressed in the same way so it was a good way to locate fixed data into (relatively) inexpensive ROM. C of the time expected to run everything in RAM after loading off disk - consts were loaded from the disk image by the C startup. The compiler enforced the 'constant type' by flagging any write to a const as an error - but nothing in the hardware actually enforced that.

    PB and MrChips are right. The optimum typing will depend on the chip you are porting to. You probably can redefine what basenear means using typedef or #define - messy but it would probably work.

    Z80 - mmmm Good times..
     
  6. Vagner Franco Pereira

    Thread Starter New Member

    Feb 10, 2015
    2
    0
    Ok, thanks. Its very hard find material about z80.
     
  7. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    Sorry about the remincing.

    You don't need to know anything about the Z80. If you are moving to ARM or some other processor, you don't need to worry about what was done on the Z80-specific typedefs etc. First, just reduce it to standard C - any ARM compiler is more than capable of figuring out where to put things. Any Z80 code is going to have specific things / types etc. that were solutions to the problems that resulted from early, small architectures. As you get into the code, you can likely make things better by employing ARM-specific compiler directives to slick things up. For now, just get it to compile by reverting all the Z80 specific stuff to standard C.

    Good luck!
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    We had Z80 systems with more than 64K of memory using memory management units. 256K and 1M were typical (ca. 1978)
     
  9. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,675
    2,724
    Yes, of course. OP said Z80. Not Z80+MMU.

    Edit: Question: Did the old Z80 compilers understand the implementation of the MMU? Or was bank switching handled manually by the programmer (or OS, if present)?
     
  10. bertus

    Administrator

    Apr 5, 2008
    15,646
    2,345
    Hello,

    I know that my old MSX2 has a Z80 and 1Mb on memory.
    The used a "memory mapper" to address the complete memory.

    Bertus
     
  11. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    Most of the MMU setups were static. They were configured at initialization and then left alone. I never saw a z80 system that did dynamic memory management although they may have existed.

    It wasn't the compilers that understood the MMU, it was the link editors. Compiler keywords or #pragma's could be added to clarify which section the code or data was destined for. Most linkage editors required a separate script to layout and produce the COFF,ELF, or other output.

    In this case the OP may not have understood the distinction between Z80 and Z80+MMU. At least from the tone of the question it seems highly probable. I also said that my impressions were educated guesses. I don't know for sure or certain.
     
Loading...