fix up simple example
authorkbongers <kbongers@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 1 Sep 2001 23:55:13 +0000 (23:55 +0000)
committerkbongers <kbongers@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 1 Sep 2001 23:55:13 +0000 (23:55 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1207 4a8a32a2-be11-0410-ad9d-d568d2c75423

device/examples/mcs51/simple/hi.c
device/examples/mcs51/simple2/hi.c

index 864ea39a679d62b7c709296f91213e2a08ba9649..636be08c8f594d95a4796069a2126cdbb2b65d95 100644 (file)
    The simulator can be used to run this program:
    s51 -Sout=serial.txt hi.ihx (run, stop, quit)
 
+   Notice that unless we use the --stack-after-data option,
+   the SSEG listed in the map is not accurate, look at the
+   .asm file and search for "sp," to see where it is really
+   initialized to.
+
  6-28-01  Written by Karl Bongers(karl@turbobit.com)
 |------------------------------------------------------------------------*/
 #include <8052.h>
@@ -36,7 +41,7 @@ bit my_bit;  // mcs51 bit variable, stored in single bit of register space
 sfr at 0xd8 WDCON;  // special function register declaration
 sbit LED_SYS = 0xb5;  // P3.5 is led, example use of sbit keyword
 
-code char my_message[] = {"GNU rocks"};  // placed in code space
+code char my_message[] = {"GNU rocks\n"};  // placed in code space
 
 void timer0_irq_proc(void) interrupt 1 using 2;
 
@@ -57,8 +62,8 @@ void timer0_irq_proc(void) interrupt 1 using 2
   }
 
   TR0 = 0; /* Stop Timer 0 counting */
-  TH0 = (~(5000)) << 8;
-  TL0 = (~(5000)) & 8;
+  TH0 = (~(5000)) >> 8;
+  TL0 = (~(5000)) & 0xff;
   TR0 = 1; /* Start counting again */
 }
 
@@ -82,10 +87,10 @@ void uart0_int(void) interrupt 4 using 1
 |------------------------------------------------------------------------*/
 void tx_char(char c)
 {
+  SBUF = c;
   while (!TI)
     ;
   TI = 0;
-  SBUF = c;
 }
 
 /*------------------------------------------------------------------------
@@ -122,9 +127,6 @@ void main(void)
   TMOD = 0x21;  /* timer control mode, byte operation */
   TCON = 0;     /* timer control register, byte operation */
 
-  TH0 = (~(5000)) << 8;  /* the initial time is not important */
-  TL0 = (~(5000)) & 8;
-
   TH1 = 0xFA;   /* serial reload value, 9,600 baud at 11.0952Mhz */
   TR1 = 1;      /* start serial timer */
 
@@ -143,8 +145,7 @@ void main(void)
   {
     if (hi_flag)
     {
-      tx_str("Hi\n");
-      tx_str("There\n");
+      tx_str("Hi There\n");
       hi_flag = 0;
     }
 
index 06f34004903e4ee7a02fa23e323837208d64ca93..241a6ad63a403d1d672639f710ce8c72a7a827ab 100644 (file)
@@ -30,10 +30,10 @@ data byte lbuf[12];  // this is our line buffer, chars gather here till CR seen
 |------------------------------------------------------------------------*/
 void tx_char(char c)
 {
+  SBUF = c;
   while (!TI)
     ;
   TI = 0;
-  SBUF = c;
 }
 
 /*------------------------------------------------------------------------