I'd like to print some output on the GB80 simulator for testing. I've tried the following:
// GPL 2.0
#include <stdio.h>
#include <stdint.h>
void main() {
printf( "Start\n" );
printf( "End\n" );
}
#ifdef __SDCC
volatile unsigned char __at 0x3fff sif;
int putchar(int c)
{
sif = 'p';
sif = c;
return c;
}
#endif
// sdcc -msm83 ./print_test83.c -o print_test83.ihx && ucsim_z80 -t GB80 -I if=rom[0x3fff] print_test83.ihx
I also tried:
// GPL 2.0
#include <stdio.h>
#include <stdint.h>
void main() {
printf( "Start\n" );
printf( "End\n" );
}
#ifdef __SDCC
volatile __sfr __at 0xff sif;
int putchar(int c)
{
sif = 'p';
sif = c;
return c;
}
#endif
// sdcc -msm83 ./print_test83.c -o print_test83.ihx && ucsim_z80 -t GB80 -I if=outputs[0xff] print_test83.ihx
Which I don't expect to work since GB80(sm83) has memory mapped I/O.
What am I doing wrong?
I'v chacked the code I figured out that sm80 simulator defines two address spaces, rom for 0-0x5fff and xram for 0xa000-0xff7f. Write operations are eliminated if address is not in xram area. As I see in map file, sdcc uses xram over 0xc000, so 0xa000-0xbfff is free for you.
For example, you can place sif at 0xbfff and start ucsim like: ucsim_z80 -tgb80 -Iif=xram[0xbfff] ...
yes, that worked. thanks.