Michael Hennebry wrote:
Perhaps putchar could be a write to a magic port.
IIRC the simulator allows a command line option to
specify that writes to a particular port go to a file.

Yep.  That does indeed work.  My "bsp.c" is
attached.  I adding a "init_bsp()" call to main
and can now run it with this command:

simulavr -d atmega128 -f dry2 -W 0x52,/dev/stderr -Texit

Is there a way to avoid having to call the init_bsp()?

It looks like there is an integer overlow in the code
now.  It likely doesn't like 16 bit integers.

I will update the issue with new code in the morning
so others can pitch in.  Or is this something that
might be a good example and just included in the
repository?

--
Joel Sherrill, Ph.D.             Director of Research & Development
[email protected]        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
  Support Available             (256) 722-9985


#include <stdio.h>

static int magic_putchar(char c, FILE *stream);

static FILE mystdout = FDEV_SETUP_STREAM(magic_putchar, NULL, _FDEV_SETUP_WRITE);

#define special_output_port (*( (volatile char *)0x52))

#define special_exit_port (*( (volatile char *)0x4F))

#define special_abort_port (*( (volatile char *)0x49))

static int magic_putchar(char c, FILE *stream)
{
  special_output_port = c;
  return 0;
}

void init_bsp(void)
{
  stdout = &mystdout;
}

_______________________________________________
Simulavr-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/simulavr-devel

Reply via email to