hello.c(1602的180行,不贴了)
/*------------------------------------------------------------------------------
hello.c
copyright 1995-2005 keil software, inc.
------------------------------------------------------------------------------*/
#include <reg52.h> /* special function register declarations */
/* for the intended 8051 derivative */
#include <stdio.h> /* prototype declarations for i/o functions */
#ifdef monitor51 /* debugging with monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* stop exection with serial intr. */
/* is enabled */
/*------------------------------------------------
the main c function. program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void) {
/*------------------------------------------------
setup the serial port for 1200 baud at 16mhz.
------------------------------------------------*/
#ifndef monitor51
scon = 0x50; /* scon: mode 1, 8-bit uart, enable rcvr */
tmod |= 0x20; /* tmod: timer 1, mode 2, 8-bit reload */
//th1 = 221; /* th1: reload value for 1200 baud @ 16mhz */
th1 = 0xfd; /*th1: reload value for 9600 baud @ 11.0592mhz */
tr1 = 1; /* tr1: timer 1 run */
ti = 1; /* ti: set ti to send first char of uart */
#endif
/*------------------------------------------------
note that an embedded program never exits (because
there is no operating system to return to). it
must loop and execute forever.
------------------------------------------------*/
while (1) {
p1 ^= 0x01; /* toggle p1.0 each time we print */
printf ("hello world\n"); /* print "hello world" */
}
}