Hi all,
I have a small system using some of Steve Cousins boards: SC108 CPU + SC110 Serial/Timer + SC129 Digital I/O and I'm trying to get a simple hello world program written in C running using z88dk.
I'm almost there but just can't figure out what the problem may be. I can build my code and it loads without error. But when I execute it, I get most of the intended character string output and then the system resets like this:
Small Computer Monitor - RC/Z80
*Ready
*g8000
Hello from z[8
Small Computer Monitor - RC/Z80
*
My hello.c file simply consists of:
#include <stdio.h>
int main()
{
printf("Hello from z88dk!\n");
}
I have a monitor.c file which I took from the z88dk
classic homebrew quickstart guide and hopefully correctly modified it to make an API call into the SCM API function $02 to output a character. The file consists of:
#include <stdio.h>
int fputc_cons_native(char c) __naked
{
__asm
pop bc ;return address
pop hl ;character to print in l
push hl
push bc
ld a,l
ld c,$02
rst $30
__endasm;
}
And I'm building the code with the command line:
zcc +z80 -clib=classic hello.c monitor.c -pragma-define:CRT_ORG_CODE=0x8000 -create-app -m -Cz--ihex
The code builds without error and I can load it fine. But when I execute it, the system resets after 12 correct characters. It's always 12 characters too.
It's obviously something very simple I'm missing - likely my inexperience with z88dk!
I'd really like to get this going as I've also got one of Steve's SC104 SIO/2 serial modules that I've modified to include an ATTINY84A to generate clock and discrete signals for the SIO/2 Channel A in synchronous mode so that the SIO/2 can interface with SPI devices. So far I've successfully talked to a Microchip 25LC256 EEPROM but I'd really like to see if it all still hangs together with FatFs and a MicroSD card. Hence the need to get a build environment setup for z88dk.
Thanks for any assistance.