hello.c

00001 /* hello.c -- Simple Hello World for 68HC11 bootstrap mode
00002    Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@nerim.fr)
00004 
00005 This file is part of GEL.
00006 
00007 GEL is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2, or (at your option)
00010 any later version.
00011 
00012 GEL is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with GEL; see the file COPYING.  If not, write to
00019 the Free Software Foundation, 59 Temple Place - Suite 330,
00020 Boston, MA 02111-1307, USA.  */
00021 
00050 #include <sys/ports.h>
00051 
00052 static void put_char (unsigned char c);
00053 static void flush (void);
00054 static void serial_print (const char* msg);
00055 void _start (void);
00056 
00057 void
00058 _start()
00059 {
00060   asm ("lds #_stack");
00061   serial_print ("Hi!\n");
00062   while (1)
00063     {
00064       serial_print ("Hello world!\n");
00065     }
00066 }
00067 
00068 static void
00069 flush ()
00070 {
00071   while (!(_io_ports[M6811_SCSR] & M6811_TDRE))
00072     continue;
00073 }
00074 
00075 static void
00076 put_char (unsigned char c)
00077 {
00078   flush ();
00079   _io_ports[M6811_SCDR] = c;
00080   _io_ports[M6811_SCCR2] |= M6811_TE;
00081 }
00082 
00083 static void
00084 serial_print (const char* msg)
00085 {
00086   while (*msg)
00087     put_char (*msg++);
00088 }