--- /dev/null
+
+#DO_GCC=1
+DO_Z80=1
+#DO_MCS51=1
+
+ifdef DO_GCC
+CC = gcc -Wall -g
+endif
+
+ifdef DO_Z80
+OBJEXT=o
+CC = sdcc
+MFLAGS = --debug -mz80
+endif
+
+ifdef DO_MCS51
+OBJEXT=rel
+CC = sdcc
+MFLAGS = --debug --model-small --stack-after-data
+#CFLAGS = -V
+#MFLAGS = --debug --model-large --stack-after-data
+#LFLAGS = --xram-loc 0x4000 --code-loc 0x0000
+endif
+
+
+#OBJECTS = test3.c itoa.$(OBJEXT) crc.$(OBJEXT)
+OBJECTS = test3.c itoa.$(OBJEXT)
+
+all: test3.ihx
+
+ifdef DO_MCS51
+an429.ihx : an429.c
+ sdcc --model-small an429.c
+
+test2.ihx : test2.c
+ sdcc --model-small test2.c
+endif
+
+%.$(OBJEXT): %.c
+ $(CC) -c $(CFLAGS) $(MFLAGS) $<
+
+itoa.rel : itoa.c
+ $(CC) -c $(CFLAGS) $(MFLAGS) itoa.c
+
+#crc.rel : crc.c
+# $(CC) -c $(CFLAGS) $(MFLAGS) crc.c
+
+test3.ihx: $(OBJECTS)
+ $(CC) $(MFLAGS) $(LFLAGS) $(OBJECTS)
+
+test3.bin: test3.ihx
+ makebin < test3.ihx > test3.bin
+
+clean:
+ rm -f core *~ \#* *.asm *.cdb *.rel *.hex *.ihx *.lst *.map *.o \
+ *.rst *.sym *.lnk *.lib *.bin
+
+testser: test3.ihx
+ s51 -Sout=serial.log test3.ihx
+
--- /dev/null
+/*------------------------------------------------------------------------
+ test3.c - A simple multiple module example, uses itoa() and crc()
+ routines from other modules in same directory. Compile with:
+ make -f maketest3
+|------------------------------------------------------------------------*/
+#if defined(__mcs51)
+#include <8052.h>
+#endif
+#if defined(__ds390)
+#include <ds390.h>
+#endif
+#include <stdio.h>
+
+typedef unsigned char byte;
+typedef unsigned int word;
+typedef unsigned long l_word;
+
+void uitoa(unsigned int value, char* string, int radix);
+void itoa(int value, char* string, int radix);
+byte accum_checksum(byte cs, byte val);
+
+char tmpstr[30];
+
+int i;
+
+#if defined(__mcs51) || defined(__ds390)
+/*------------------------------------------------------------------------
+ tx_char - transmit(tx) a char out the serial uart.
+|------------------------------------------------------------------------*/
+void tx_char(char c)
+{
+ SBUF = c;
+ while (!TI)
+ ;
+ TI = 0;
+}
+
+/*------------------------------------------------------------------------
+ my_puts -
+|------------------------------------------------------------------------*/
+void my_puts(char *str)
+{
+
+ while (*str)
+ tx_char(*str++);
+}
+
+/*------------------------------------------------------------------------
+ init_mcs51 -
+|------------------------------------------------------------------------*/
+void init_mcs51(void)
+{
+ PCON = 0x80; /* power control byte, set SMOD bit for serial port */
+ SCON = 0x50; /* serial control byte, mode 1, RI active */
+ TMOD = 0x21; /* timer control mode, byte operation */
+ TCON = 0; /* timer control register, byte operation */
+
+ TH1 = 0xFA; /* serial reload value, 9,600 baud at 11.0952Mhz */
+ TR1 = 1; /* start serial timer */
+
+ EA = 1; /* Enable Interrupts */
+
+ TI = 0; /* clear this out */
+}
+#else
+/*------------------------------------------------------------------------
+ my_puts -
+|------------------------------------------------------------------------*/
+void my_puts(char *str)
+{
+
+ while (*str)
+ putchar(*str++); /* putchar() is lib routine which calls simulator trap */
+}
+#endif
+
+/*------------------------------------------------------------------------
+ main - Simple test program to send out something to the serial port.
+|------------------------------------------------------------------------*/
+int main(void)
+{
+ byte ccs;
+ unsigned int tmp;
+
+#if defined(__mcs51) || defined(__ds390)
+ init_mcs51();
+#endif
+
+ ccs = 0x3f;
+ tmp = (ccs<<7);
+ my_puts("0x3f<<7 hex=");
+ uitoa(tmp, tmpstr, 10);
+ my_puts(tmpstr);
+ my_puts("\n");
+
+#if 0
+ byte r,cs,val;
+ unsigned int tmp;
+ cs = 0xff;
+ val = 0;
+ tmp = ((cs<<7) | (cs>>1)) + val;
+ printf("tmp=%xH(0x7fff)\n", tmp);
+ cs = 0xfd;
+ tmp = ((cs<<7) | (cs>>1)) + val;
+ printf("tmp=%xH(0x7efe)\n", tmp);
+ // return (byte)tmp + ((byte) (tmp>>8) & 1);
+#endif
+
+
+ my_puts("Test3 - multiple module test\n");
+
+ my_puts("1023 decimal=");
+ uitoa(1023, tmpstr, 10);
+ my_puts(tmpstr);
+ my_puts(" hex=");
+ uitoa(1023, tmpstr, 0x10);
+ my_puts(tmpstr);
+ my_puts("\n");
+
+ my_puts(" chksum=");
+// i = accum_checksum(50, 20);
+ uitoa(i, tmpstr, 10);
+ my_puts(tmpstr);
+ my_puts("\n");
+
+ for (;;)
+ {
+ }
+ return 0;
+}
+