Excuse my english, because my native language is german :-)
I created a Z80 minimum system on a breadboard, with CPU, PIO, 8255 and ADC. Because I dont want to write a monito0r in ASM, for communication with a linux pc, I want to use sdcc. Also for uploading programs later to the Z80 machine. The z80 only communicates via USB to the Linux PC, programs are compiled on the PC and transfered to the Z80 RAM and then excetuted.
My memory map is:
ROM 0 - 0x1fff
RAM 2000-7FFF
see attrached file for schematic.
IO: ....
First steps are the most diffcult ones, to I need a template for Z80 source code with all necessary settings and I/O Adressing, special words etc. The startup code has to be included. Dont know but I think a JUMP at 0x0000 to the first instruction at 0x0100 is necessary. I dont know if it possible to make SDCC create an interrupt vector table at the right place eg for NMI.
Can you help me please? Maybe with a complete project?
I can't help much, but I can point you to a project I did some time ago,
with a simple Z80 system as well but using FPGA.
I remember to have prepared a very basic IO lib to make it possible to
develop using SDCC and access the hardware on my system.
I really think you can take a look at the lib, it may give you some ideas.
Excuse my english, because my native language is german :-)
I created a Z80 minimum system on a breadboard, with CPU, PIO, 8255 and
ADC. Because I dont want to write a monito0r in ASM, for communication with
a linux pc, I want to use sdcc. Also for uploading programs later to the
Z80 machine. The z80 only communicates via USB to the Linux PC, programs
are compiled on the PC and transfered to the Z80 RAM and then excetuted.
My memory map is:
ROM 0 - 0x1fff
RAM 2000-7FFF
IO: ....
First steps are the most diffcult ones, to I need a template for Z80
source code with all necessary settings and I/O Adressing, special words
etc. I dont know if it possible to make SDCC create an interrupt vector
table at the right place eg for NMI.
In my lib, I adapted crt0.s to my system and replaced the one that comes
with SDCC.
So, I think you should search for the crt0.s on the system where you
installed SDCC - you might find several. Depending on the parameters you
pass to SDCC, it will choose the crt0.s more adequate to your device - that
is the one you want to replace.
An overview of the libs - since you though it was too complex...
In de1.h I define the IO and memory addresses for the system:
define PLATFORM 0
define RAMSIZE 40959
define CHEXLSB 0x11
define CHEXMSB 0x10
define RAMMEM 0x6000
define VIDEOMEM 0x4000
extern void redLeds(short int byte);
extern void hexlsb(short int byte);
extern void hexmsb(short int byte);
In de1.c it is defined the functions to access the hardware:
include <de1.h>
include <z80soc.h>
include <string.h>
void redLeds(short int byte) { sfr at RLEDSPORT static RLEDIOPort;
RLEDIOPort = byte;
}
void hexlsb(short int byte) { sfr at CHEXLSB static HEX01;
HEX01 = byte;
}
void hexmsb(short int byte) { sfr at CHEXMSB static HEX23;
HEX23 = byte;
}
For simplicity (and due to laziness), I defined getchar and putchar inside
crt0.s (take a look).
All useful functions to access the Z80SOC hardware is on z80soc.c.
For example, there you will find functions to read keyboard, clear screen,
move bytes between memory addresses, read dip switches, turn leds on and
off, and so on.
it works! I found a page who explans it and i recompiled my .s file with the correct values. But it is tricky: The startup code starts at 0x100 and my main has to start an 0x110, otherwise there is an overlapping. also the sdcc has a bug. I have to compile each file with -c option and after I have to link them together. If not, a simple array is linked into rom, instead of ram. dont knwo the reason but this bug was reported on this page.
Works fine, the Z80 is alive!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Christian!
Congrats for such a neat design and for kicking it alive!
How did You plan in advance Your hardware reference design, expecially how did You solve I/O port addressing of ADC peripheral and memory mapped addressing of external RAM + EEPROM ??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Christian, I will look at this board schematic with attention, comparing it with other solutions such as MSX1 typical layer or Sinclair's Spectrum.
Keep it up!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello!
Excuse my english, because my native language is german :-)
I created a Z80 minimum system on a breadboard, with CPU, PIO, 8255 and ADC. Because I dont want to write a monito0r in ASM, for communication with a linux pc, I want to use sdcc. Also for uploading programs later to the Z80 machine. The z80 only communicates via USB to the Linux PC, programs are compiled on the PC and transfered to the Z80 RAM and then excetuted.
My memory map is:
ROM 0 - 0x1fff
RAM 2000-7FFF
see attrached file for schematic.
IO: ....
First steps are the most diffcult ones, to I need a template for Z80 source code with all necessary settings and I/O Adressing, special words etc. The startup code has to be included. Dont know but I think a JUMP at 0x0000 to the first instruction at 0x0100 is necessary. I dont know if it possible to make SDCC create an interrupt vector table at the right place eg for NMI.
Can you help me please? Maybe with a complete project?
Best regards from Cologne,
Christian
Last edit: Christian Julius 2014-10-01
Hi Christian.
I can't help much, but I can point you to a project I did some time ago,
with a simple Z80 system as well but using FPGA.
I remember to have prepared a very basic IO lib to make it possible to
develop using SDCC and access the hardware on my system.
I really think you can take a look at the lib, it may give you some ideas.
Project is Z80SoC v0.7.2 https://sites.google.com/site/z80soc/, and the
lib can be found here https://sites.google.com/site/z80soc/file-cabinet.
cheers
Roni
On 1 October 2014 21:21, Christian Julius superhobel@users.sf.net wrote:
I have 24mb of Z-80 schematics, code, and articles.
I zipped them into a 13mb file and put them here for you.
http://neatinfo.com/temp/
Hi Roni,
i had a quick look over the files but this seems to be to complex for understanding during the first hours.
My main problem is:
The asm code and the map do not show anything like a vector table and the first instruction at 0x0000 is not a jump to main, its main itsself.
In my lib, I adapted crt0.s to my system and replaced the one that comes
with SDCC.
So, I think you should search for the crt0.s on the system where you
installed SDCC - you might find several. Depending on the parameters you
pass to SDCC, it will choose the crt0.s more adequate to your device - that
is the one you want to replace.
An overview of the libs - since you though it was too complex...
In de1.h I define the IO and memory addresses for the system:
define PLATFORM 0
define RAMSIZE 40959
define CHEXLSB 0x11
define CHEXMSB 0x10
define RAMMEM 0x6000
define VIDEOMEM 0x4000
extern void redLeds(short int byte);
extern void hexlsb(short int byte);
extern void hexmsb(short int byte);
In de1.c it is defined the functions to access the hardware:
include <de1.h>
include <z80soc.h>
include <string.h>
void redLeds(short int byte) {
sfr at RLEDSPORT static RLEDIOPort;
RLEDIOPort = byte;
}
void hexlsb(short int byte) {
sfr at CHEXLSB static HEX01;
HEX01 = byte;
}
void hexmsb(short int byte) {
sfr at CHEXMSB static HEX23;
HEX23 = byte;
}
For simplicity (and due to laziness), I defined getchar and putchar inside
crt0.s (take a look).
All useful functions to access the Z80SOC hardware is on z80soc.c.
For example, there you will find functions to read keyboard, clear screen,
move bytes between memory addresses, read dip switches, turn leds on and
off, and so on.
Hoep this helps.
Roni
On 1 October 2014 22:58, Christian Julius superhobel@users.sf.net wrote:
On 01.10.2014 23:58, Christian Julius wrote:
Assemble it, and link the resulting crt0.rel like you would any other
.rel generated by the compiler.
Philipp
Hi Roni,
it works! I found a page who explans it and i recompiled my .s file with the correct values. But it is tricky: The startup code starts at 0x100 and my main has to start an 0x110, otherwise there is an overlapping. also the sdcc has a bug. I have to compile each file with -c option and after I have to link them together. If not, a simple array is linked into rom, instead of ram. dont knwo the reason but this bug was reported on this page.
Works fine, the Z80 is alive!
Hi Christian!
Congrats for such a neat design and for kicking it alive!
How did You plan in advance Your hardware reference design, expecially how did You solve I/O port addressing of ADC peripheral and memory mapped addressing of external RAM + EEPROM ??
Hi,
I attach my desihn to this mail. There are lots of problems to be solved but I am working on them.
Thanks Christian, I will look at this board schematic with attention, comparing it with other solutions such as MSX1 typical layer or Sinclair's Spectrum.
Keep it up!