This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Getting stdin, stdout


"Russ.Shaw" wrote:
> 
> Hi all,
> 
> I'm using a hitachi H8/3048F micro in a wire-wrap system,
> and want to use scanf and printf, which requires stdin and
> stdout. I wan't to use a serial port for stdin/out.
> 
> There are io functions and macros in stdio.h, but its not
> obvious how i should modify or overide them in my own
> program. Anyone know how?

 The low-level I/O-routines read() and write() handle these
things, so just modify them for your needs. The calling
conventions etc. are handled in the newlib, GNUPro etc. docs.
The newlib docs come with newlib sources, the GNUPro docs
come with the GNUPro distributions, like those from Hitachi
(the '98r2' in their free 2000 CDROM and the '99r1p1' now
available via download).

 Here is the default 'write()' coming with newlib in 'write.c':

----------------------- clip ---------------------
int _write(file, ptr, len)
     int file;
     char *ptr;
     int len;
{
  int todo;
  
  for (todo = 0; todo < len; todo++) 
    {
      asm("mov.b #0,r1l\n mov.b %0l,r2l\njsr @@0xc4"   :  : "r" (*ptr++)  : "r1", "r2");
    }
  return len;
}
----------------------- clip ---------------------

and here the 'read()' in 'syscalls.c':

----------------------- clip ---------------------
/* Operating system stubs, set up for the MRI simulator */

#include <_ansi.h>
#include <sys/types.h>
#include <sys/stat.h>

int _DEFUN(_read,(file, ptr, len),
	   int file _AND
	   char *ptr _AND
	   int len)
{
  return 0;
}
----------------------- clip ---------------------

 So the 'read()' does nothing now.

> BTW, i'm using gcc-2.95.2, newlib-1.8.2, etc on a pc
> with gnu/linux.

 ...but this doesn't disable one using the HTML and PDF docs
from the Hitachi distributions, although the InstallShield-
packaged Win32-distributions may be a nuisance...

Cheers, Kai



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]