/****************************************************************************
** File Name: main.c
** Description:
** Generated Automatically for: ARM7TDMI-S3c4510b Evaluation Board.
** Time: Monday, May 26, 2003 11:08:05
** Copyright 1999-2004 Jedi Systems Inc.
****************************************************************************/
#include <string.h>
#include <stdio.h>
#include "uart_ev44b0.h"
//static char buf[100];
//static int j=0;
extern int clock_init();
extern int port_init(int);
int _write (int file, char *ptr, int len);

void print (char *ptr);

int main() 
{ 
        int i;
        char *str = "abcdefg\nhijklnmopqrstuvwxy1234567\n";
        char buf[100];
//        char p[100];
        i = sizeof (str);

        clock_init();       //init clock
        port_init(0);       //init port
        /* test our serial I/O */
        dev_uart_init (0, 0, 0);

        crtio (115200);  /* change baund rate */
        buf[18] = 0;
        printf ("printed by printf\n");
        printf ("printed by printf again\n");
        printf("%f\n",128.001);
         //   print(str); 
        //        _write (1, str, 18);
        //printf ("printed byte(s) of str is: %d \n", i);
        
        while (1) {
                if ((i = inbyte()) != EOF) {
                        buf[0] = (char)i;
                        break;
                }
        }
       
        return (i);
} 


/*
 * print -- do a raw print of a string
 */
void print (char *ptr)
{
	//int z;
        while (*ptr) {
                outbyte(*ptr++);
                /*
                while (1) {
                	if ((z = inbyte()) != EOF) {
                		buf[j++] = (char)z;
                		break;
               		}
               	}
               	*/
        }
}

/* my own _write */
#if 0
int _write (int file, char *ptr, int len)
{
        int i;

        for (i = 0; i< len; i++) {
                outbyte (*ptr++);
        }
        /*
          while (*ptr) {
          outbyte (*ptr++);
          }
        */
        return (1);
}
//#else
int _write (int fd, char *buf, int nbytes)
{
  int i;

  for (i = 0; i < nbytes; i++) {
    if (*(buf + i) == '\n') {
      outbyte ('\r');
    }
    outbyte (*(buf + i));
  }
  return (nbytes);
}
#endif
void _exit (int n)
{
  /* FIXME: return code is thrown away.  */
  n = n;
}

void initialise_monitor_handles (void)
{

}






