1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Z80 C Compiler (compile as a intel hex?)

Discussion in 'Members Lounge' started by Marks256, Jan 12, 2007.

  1. Marks256

    Marks256 New Member

    Joined:
    Jul 14, 2006
    Messages:
    2,350
    Likes:
    9
    Location:
    Minnesota, USA
    Does anyone know of a C compiler for the Z80? I figure that since i am already learning C, i might as well keep at it, as assemlby scares me... :D

    I would like it if the C compiler would compile the code into a HEX file so i can burn it to (EE)PROM.

    I did find a few, but their links were dead, and the other one didn't work...
     
  2. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    You should try using google sometime =)
    http://www.bdsoft.com/resources/bdsc.html

    Don't be afraid of assembly, it's not so difficult as all that it just takes a little time to get use to. If you intend on doing any highly efficient or heavy processing on a micro controller you're really going to want to learn assembly as a smart assembly routine can execute in significantly less time than a more generic multipurpose C routine.
     
  3. Marks256

    Marks256 New Member

    Joined:
    Jul 14, 2006
    Messages:
    2,350
    Likes:
    9
    Location:
    Minnesota, USA
    I found that site about six or seven times while looking for one...

    Ok, i have some questions about assembly, then.

    1) How are variables assigned? Can you even assign variables, or do you have to know where you put it in memory?
    2) How do you do conditionals (if...then...else)
    3) are outputs as simple as using the "out" opcode?
    4) on the same note, are inputs just as simple as the "inp" opcode?
    5) How hard are float point variables?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. hjames

    hjames New Member

    Joined:
    Jun 7, 2006
    Messages:
    677
    Likes:
    6
    Location:
    Bezerkeley, USA

    1) Variables?! You get registers and memory. Keep in mind that variables are an abstraction that high level languages give you - they're actually some combination of registers and memory locations. Typically assemblers allow you to allocate static memory using some assembler directives (something like "db foo" to allocate a byte worth of memory, and name it "foo"). The other two ways to allocate memory are on the "stack", or to just dynamically allocate it from the main memory.
    2) There are a bunch of status flags in status register which are usually named "zero", "negative", "carry", etc. These flags are set when you call a comparison op, or when you perform certain math ops. There is a set of conditional jumps which look at these status bits and do stuff like "jump to address x if zero flag is set".
    3) yup.
    4) yup.
    5) very, if you don't have a library.
     
  6. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    Yeah. ASM is a little daunting because you have to do it ALL. Floating point math is not something you want to do yourself. It's usually best to keep things in interger land. If you need to deal with really large and really small numbers at the same time frequently stick with C. As long as there isn't a huge variation in the range of numbers you need you can do quiet a bit of math using only intergers.
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,331
    Likes:
    653
    Location:
    Derbyshire, UK
    Floating point maths is only very rarely required, it's slow, takes lots of space, and is inaccurate - far better to use integers instead, which is often simple with a little thought. This also applies to PC's, never mind micro-controllers!.

    If there is ever a need to use them?, it's reasonably simple in assembler - you just download some floating point routines. You simply load your values into variables, call the routine you want, and read the result back. This is just how a high level language would do the same job - it just hides it from you.

    And all this fuss Marks256 has been making about Z80, now he's decided he only wants to write in C! - so what's the point of building a Z80 system?, C hides that fact from you - may as well just use a single chip PIC or AVR which will out perform a Z80 at a fraction of the cost.

    BTW Marks256, - if assembler scares you, go for PIC rather than AVR (or Z80), it's generally considered the simplest to learn (hence the PIC's popularity).
     
  8. Marks256

    Marks256 New Member

    Joined:
    Jul 14, 2006
    Messages:
    2,350
    Likes:
    9
    Location:
    Minnesota, USA
    Nah. Tasm looks pretty promising... And the z80 looks cool...

    I like to be scared.... :D
     
  9. i_build_stuff

    i_build_stuff New Member

    Joined:
    Jul 21, 2005
    Messages:
    135
    Likes:
    1
    Location:
    Pittsburgh, PA (USA)
    I haven't used it personally, but SDCC is a free (GPL'd) C compiler that supports Z80. Some people have complained that it's hard to use, but it doesn't really look any more complicated than GCC.

    http://sdcc.sourceforge.net/
     
  10. Marks256

    Marks256 New Member

    Joined:
    Jul 14, 2006
    Messages:
    2,350
    Likes:
    9
    Location:
    Minnesota, USA
    I came across that site when i was searching, but it was down when i found it... Thanks...
     

Share This Page