; 80166 C compiler v5.1 r0               SN077933-093 (C)1996 Tasking Software BV
; options: -x -s -Ms
$EXTEND
$NOMOD166
$STDNAMES(reg.def)
$CASE
$MODEL(SMALL)
	NAME	_DOPRINT
; _doprint.c    1	/*
; _doprint.c    2	 *      @(#)_doprint.c  1.14
; _doprint.c    3	 */
; _doprint.c    4	
; _doprint.c    5	/**************************************************************************
; _doprint.c    6	**                                                                        *
; _doprint.c    7	**  FILE        :  _doprint.c                                             *
; _doprint.c    8	**                                                                        *
; _doprint.c    9	**  DESCRIPTION :  Source file for _doprint() routine                     *
; _doprint.c   10	**                 This routine is used to create all different           *
; _doprint.c   11	**                 formatting routines for _printf().                     *
; _doprint.c   12	**                 when SMALL is defined, a version without floating      *
; _doprint.c   13	**                 point is created, and no length specifiers, etc. are   *
; _doprint.c   14	**                 supported.                                             *
; _doprint.c   15	**                 when MEDIUM is defined, a version without floating     *
; _doprint.c   16	**                 point is created.                                      *
; _doprint.c   17	**                 Default, an ANSI version is created.                   *
; _doprint.c   18	**                                                                        *
; _doprint.c   19	**  NOTE        :  One thing in this formatter (specially designed for    *
; _doprint.c   20	**                 C166) is the printing of pointer values                *
; _doprint.c   21	**                 '%p' will print a 'default' pointer (ANSI)             *
; _doprint.c   22	**                 '%hp' will always print a 'near' pointer               *
; _doprint.c   23	**                 '%lp' will always print a 'far' pointer                *
; _doprint.c   24	**                 '%Lp' will always print a 'huge' pointer               *
; _doprint.c   25	**                                                                        *
; _doprint.c   26	**                 Define :                                               *
; _doprint.c   27	**                 SMALL  - No floats, no length specifiers (default)     *
; _doprint.c   28	**                 MEDIUM - No floats                                     *
; _doprint.c   29	**                 LARGE  - Full ANSI formatter                           *
; _doprint.c   30	**                                                                        *
; _doprint.c   31	**  COPYRIGHT   :  1995 Tasking Software B.V.                             *
; _doprint.c   32	**                                                                        *
; _doprint.c   33	**************************************************************************/
; _doprint.c   34	
; _doprint.c   35	#include <stdarg.h>
; _doprint.c   36	#include <errno.h>
; _doprint.c   37	#include <string.h>
; _doprint.c   38	#include <stdio.h>
; _doprint.c   39	#include <string.h>
; _doprint.c   40	
; _doprint.c   41	//#if !defined SMALL && !defined MEDIUM && !defined LARGE
; _doprint.c   42	//#define       SMALL           /* Default formatter */
; _doprint.c   43	//#endif
; _doprint.c   44	
; _doprint.c   45	#undef SMALL
; _doprint.c   46	#undef MEDIUM
; _doprint.c   47	#define LARGE  // Aenderung von Wilhelm Brezovits am 7. Mai 1996
; _doprint.c   48	
; _doprint.c   49	
; _doprint.c   50	/* Print a string (without newline) */
; _doprint.c   51	static void _fputs( char *str, FILE *fout, unsigned int *characters );
; _doprint.c   52	
; _doprint.c   53	/* convert an unsigned int to a string                  */
; _doprint.c   54	extern char * _ltoa( char *p, unsigned long num, unsigned char radix );
; _doprint.c   55	
; _doprint.c   56	/* Print a character in hexadecimal format */
; _doprint.c   57	static void _printhex( unsigned char c, FILE *fout, unsigned int *characters );
; _doprint.c   58	
; _doprint.c   59	#ifndef SMALL
; _doprint.c   60	static void _putstring( unsigned char format, int min, int max,
; _doprint.c   61				char *str, FILE *fout, unsigned int *characters );
; _doprint.c   62	static void _putnumber( int min, int max, unsigned char ch, unsigned char format,
; _doprint.c   63				void *pvalue, FILE *fout, unsigned int *characters );
; _doprint.c   64	#else
; _doprint.c   65	#define _putstring( x, y, z )   _fputs( x, y, z )
; _doprint.c   66	static void _putnumber( unsigned char ch, unsigned char format,
; _doprint.c   67				void *pvalue, FILE *fout, unsigned int *characters );
; _doprint.c   68	#endif
; _doprint.c   69	
; _doprint.c   70	/* Print one character in hexadecimal format */
; _doprint.c   71	static void
; _doprint.c   72	_printhex( unsigned char c, FILE *fout, unsigned int *characters )
; _doprint.c   73	{
; cha = R6 (automatic)
_DOPRINT_1_PR	SECTION	CODE WORD PUBLIC 'CPROGRAM'
__printhex	PROC	FAR
; c = R7 (parameter: R12 copied)
; fout = R9 (parameter: R13 copied)
; characters = offset 6 (parameter: R14 pushed)
; Stack: 8, CSE: 0 offset 0
	MOV	[-R0],R14
	MOV	[-R0],R9
	MOV	[-R0],R7
	MOV	[-R0],R6
	MOV	R7,R12
	MOV	R9,R13
; _doprint.c   74		unsigned char cha;
; _doprint.c   75	
; _doprint.c   76		*characters += 2;
	MOV	R4,[R0+#06H]
	MOV	R5,[R4]
	ADD	R5,#02h
	MOV	[R4],R5
; _doprint.c   77		cha = (c >> 4) & 0x0F;
	MOVBZ	R4,RL7
	MOVBZ	R4,RL4
	SHR	R4,#04h
	MOVB	RL6,RL4
	ANDB	RL6,#0Fh
; _doprint.c   78		cha += cha > 9 ? 'A'-10 : '0';
	CMPB	RL6,#09h
	JMPR	cc_ULE,_3
_4:
	MOVB	RL4,#037h
	JMPR	cc_UC,_5
_3:
	MOVB	RL4,#030h
_5:
	ADDB	RL6,RL4
; _doprint.c   79		fputc( cha, fout );
	MOVBZ	R12,RL6
	MOV	R13,R9
	CALLS	SEG _fputc,_fputc
; _doprint.c   80		cha = c & 0x0F;
	MOVB	RL6,#0Fh
	ANDB	RL6,RL7
; _doprint.c   81		cha += cha > 9 ? 'A'-10 : '0';
	CMPB	RL6,#09h
	JMPR	cc_ULE,_6
_7:
	MOVB	RL4,#037h
	JMPR	cc_UC,_8
_6:
	MOVB	RL4,#030h
_8:
	ADDB	RL6,RL4
; _doprint.c   82		fputc( cha, fout );
	MOVBZ	R12,RL6
	MOV	R13,R9
	CALLS	SEG _fputc,_fputc
; _doprint.c   83	}
	MOV	R6,[R0+]
	MOV	R7,[R0+]
	MOV	R9,[R0+]
	ADD	R0,#02h
	RETS
__printhex	ENDP
; _doprint.c   84	
; _doprint.c   85	/* Floating point formatter */
; _doprint.c   86	#ifdef  LARGE
; _doprint.c   87	extern void     _doflt( int min, int max, unsigned char ch, unsigned char format,
; _doprint.c   88				double *pvalue, FILE *fout, unsigned int *characters );
; _doprint.c   89	#endif
; _doprint.c   90	
; _doprint.c   91	/* does the actual printing     */
; _doprint.c   92	int
; _doprint.c   93	_doprint( register const char *fmt, va_list ap, FILE *fout )
; _doprint.c   94	{
	PUBLIC	__doprint
; format = R6 (automatic)
; ch = R7 (automatic)
; max = R9 (automatic)
; min = R8 (automatic)
; characters = offset 0 (automatic)
; cc = offset 2 (automatic)
; mxflg = offset 3 (automatic)
__doprint	PROC	FAR
; fmt = offset 12 (parameter: R12 pushed)
; ap = offset 14 (parameter: R13 pushed)
; fout = offset 16 (parameter: R14 pushed)
; Stack: 18, CSE: 0 offset 0
	MOV	[-R0],R14
	MOV	[-R0],R13
	MOV	[-R0],R12
	MOV	[-R0],R9
	MOV	[-R0],R8
	MOV	[-R0],R7
	MOV	[-R0],R6
	SUB	R0,#04h
; _doprint.c   95	
; _doprint.c   96	#ifndef SMALL
; _doprint.c   97		register int min;               /* minimum length of output field */
; _doprint.c   98		register int max;               /* maximum length of output field */
; _doprint.c   99	#endif
; _doprint.c  100	
; _doprint.c  101		register unsigned char ch;      /* character in format string     */
; _doprint.c  102		register unsigned char format;  /* b6 - left alignment            */
; _doprint.c  103						/* b5 - zero fill                 */
; _doprint.c  104						/* b4 - alternate print           */
; _doprint.c  105						/* b3,b2 - 0x04 --> always sign   */
; _doprint.c  106						/*       - 0x08 --> sign or space */
; _doprint.c  107						/* b1,b0 - 0x01 --> short         */
; _doprint.c  108						/*       - 0x02 --> long          */
; _doprint.c  109						/*       - 0x03 --> double        */
; _doprint.c  110		unsigned char mxflg = 0;        /* Flag if a maximum length */
	MOVB	RL4,#00h
	MOVB	[R0+#03H],RL4
; _doprint.c  111						/* specifier is found */
; _doprint.c  112	
; _doprint.c  113		unsigned int characters = 0;    /* no characters written yet      */
	MOV	R4,#00h
	MOV	[R0],R4
; _doprint.c  114	
; _doprint.c  115		for( ;; )
_12:
_13:
_14:
_15:
_16:
_17:
_18:
_19:
; _doprint.c  116		{
; _doprint.c  117			ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
; _doprint.c  118			if( !ch )
	JMPA	cc_Z,_78
; _doprint.c  119			{
; _doprint.c  120				return( characters );
; _doprint.c  121			}
; _doprint.c  122			else if( ch == '%' )
	CMPB	RL7,#025h
	JMPR	cc_NE,_20
; _doprint.c  123			{
; _doprint.c  124				if( *fmt != '%' )
	MOV	R4,[R0+#0CH]
	MOVB	RL5,[R4]
	CMPB	RL5,#025h
	JMPR	cc_NE,_21
; _doprint.c  125					goto nxt;
; _doprint.c  126				fmt++;
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
; _doprint.c  127			}
_20:
; _doprint.c  128			characters++;
	MOV	R4,[R0]
	ADD	R4,#01h
	MOV	[R0],R4
; _doprint.c  129			fputc( ch, fout );
	MOVBZ	R12,RL7
	MOV	R13,[R0+#010H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  130			continue;
	JMPR	cc_UC,_19
; _doprint.c  131	
; _doprint.c  132			nxt:
_21:
; _doprint.c  133	
; _doprint.c  134	#ifndef SMALL
; _doprint.c  135			format = min = max = 0;
	MOV	R4,#00h
	MOV	R9,R4
	MOV	R8,R4
	MOVB	RL6,RL4
; _doprint.c  136	#else
; _doprint.c  137			format = 0;
; _doprint.c  138	#endif
; _doprint.c  139	
; _doprint.c  140	#ifndef SMALL
; _doprint.c  141			while( 1 )
_22:
_23:
_24:
_25:
_26:
_27:
; _doprint.c  142			{
; _doprint.c  143				ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
; _doprint.c  144				if( ch == '-' )
	CMPB	RL7,#02Dh
	JMPR	cc_NE,_28
; _doprint.c  145					format |= 0x40; /* left alignment */
	ORB	RL6,#040h
	JMPR	cc_UC,_27
_28:
; _doprint.c  146				else if( ch == '+' )
	CMPB	RL7,#02Bh
	JMPR	cc_NE,_29
; _doprint.c  147					format = (format & 0xF3) | 0x04;
	MOVB	RL4,#0F3h
	ANDB	RL4,RL6
	ORB	RL4,#04h
	MOVB	RL6,RL4
	JMPR	cc_UC,_26
_29:
; _doprint.c  148				else if( ch == ' ' )
	CMPB	RL7,#020h
	JMPR	cc_NE,_30
; _doprint.c  149				{
; _doprint.c  150					/* do not overrule '+'  */
; _doprint.c  151					if( !(format & 0x0C) )
	MOVB	RL4,#0Ch
	ANDB	RL4,RL6
	JMPR	cc_NZ,_25
; _doprint.c  152						format |= 0x08; /* sign or space */
	ORB	RL6,#08h
; _doprint.c  153				}
	JMPR	cc_UC,_24
_30:
; _doprint.c  154				else if( ch == '0' )
	CMPB	RL7,#030h
	JMPR	cc_NE,_31
; _doprint.c  155					format |= 0x20; /* zero fill */
	ORB	RL6,#020h
	JMPR	cc_UC,_23
_31:
; _doprint.c  156				else if( ch == '#' )
	CMPB	RL7,#023h
	JMPR	cc_NE,_32
; _doprint.c  157					format |= 0x10; /* alternate print */
	ORB	RL6,#010h
	JMPR	cc_UC,_22
; _doprint.c  158				else
; _doprint.c  159					break;
; _doprint.c  160			}
_32:
; _doprint.c  161	
; _doprint.c  162			if( ch == '*' )
	CMPB	RL7,#02Ah
	JMPR	cc_NE,_35
; _doprint.c  163			{       /* next argument is minimum field width specifier */
; _doprint.c  164				min = va_arg( ap, int );
	MOV	R4,[R0+#0EH]
	MOV	R2,#02h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
	MOV	R8,[R5]
; _doprint.c  165				if( min < 0 )
	CMP	R8,#00h
	JMPR	cc_SGE,_33
; _doprint.c  166				{
; _doprint.c  167					format |= 0x40;
	ORB	RL6,#040h
; _doprint.c  168					min = -min;
	MOV	R4,R8
	NEG	R4
	MOV	R8,R4
; _doprint.c  169				}
_33:
; _doprint.c  170				ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
; _doprint.c  171			}
	JMPR	cc_UC,_37
; _doprint.c  172			else
; _doprint.c  173			{
; _doprint.c  174				while( ch >= '0' && ch <= '9' )
_34:
; _doprint.c  175				{       /* get minimum field width */
; _doprint.c  176					min = min * 10 + ch - '0';
	MOV	R4,R8
	SHL	R4,#02h
	ADD	R4,R8
	SHL	R4,#01h
	MOVBZ	R5,RL7
	ADD	R4,R5
	SUB	R4,#030h
	MOV	R8,R4
; _doprint.c  177					ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
_35:
	CMPB	RL7,#030h
	JMPR	cc_ULT,_37
	CMPB	RL7,#039h
	JMPR	cc_ULE,_34
; _doprint.c  178				}
; _doprint.c  179			}
_37:
; _doprint.c  180			if( ch == '.' )
	CMPB	RL7,#02Eh
	JMPR	cc_NE,_43
; _doprint.c  181			{       /* next argument is maximum field width specifier */
; _doprint.c  182				format &= ~0x20;        /* zero fill must be disabled */
	ANDB	RL6,#0DFh
; _doprint.c  183				mxflg = 1;              /* read a value for 'max' */
	MOVB	RL4,#01h
	MOVB	[R0+#03H],RL4
; _doprint.c  184				if( (ch = *fmt++) == '*' )
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
	MOVB	RL5,[R4]
	CMPB	RL5,#02Ah
	JMPR	cc_NE,_40
; _doprint.c  185				{
; _doprint.c  186					max = va_arg( ap, int );
	MOV	R4,[R0+#0EH]
	MOV	R2,#02h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
	MOV	R9,[R5]
; _doprint.c  187					if( max < 0 )
	CMP	R9,#00h
	JMPR	cc_SGE,_38
; _doprint.c  188					{
; _doprint.c  189						format |= 0x40;
	ORB	RL6,#040h
; _doprint.c  190						max = -max;
	MOV	R4,R9
	NEG	R4
	MOV	R9,R4
; _doprint.c  191					}
_38:
; _doprint.c  192					ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
; _doprint.c  193				}
	JMPR	cc_UC,_43
; _doprint.c  194				else
; _doprint.c  195				{
; _doprint.c  196					while( ch >= '0' && ch <= '9' )
_39:
; _doprint.c  197					{       /* get maximum field width */
; _doprint.c  198						max = max * 10 + ch - '0';
	MOV	R4,R9
	SHL	R4,#02h
	ADD	R4,R9
	SHL	R4,#01h
	MOVBZ	R5,RL7
	ADD	R4,R5
	SUB	R4,#030h
	MOV	R9,R4
; _doprint.c  199						ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
_40:
	CMPB	RL7,#030h
	JMPR	cc_ULT,_43
	CMPB	RL7,#039h
	JMPR	cc_ULE,_39
; _doprint.c  200					}
; _doprint.c  201				}
; _doprint.c  202			}
; _doprint.c  203	#else
; _doprint.c  204			ch = *fmt++;
; _doprint.c  205	#endif
; _doprint.c  206	
; _doprint.c  207			do
_43:
; _doprint.c  208			{
; _doprint.c  209				if( ch == 'l' )
	CMPB	RL7,#06Ch
	JMPR	cc_NE,_44
; _doprint.c  210				{
; _doprint.c  211					format |= 0x02;
	ORB	RL6,#02h
; _doprint.c  212				}
	JMPR	cc_UC,_47
_44:
; _doprint.c  213				else if( ch == 'h' )
	CMPB	RL7,#068h
	JMPR	cc_NE,_45
; _doprint.c  214				{
; _doprint.c  215					format |= 0x01;
	ORB	RL6,#01h
; _doprint.c  216				}
	JMPR	cc_UC,_47
_45:
; _doprint.c  217				else if( ch == 'L' )
	CMPB	RL7,#04Ch
	JMPR	cc_NE,_48
; _doprint.c  218				{
; _doprint.c  219					format |= 0x03;
	ORB	RL6,#03h
; _doprint.c  220				}
; _doprint.c  221				else
; _doprint.c  222					continue;
_47:
; _doprint.c  223	
; _doprint.c  224				ch = *fmt++;
	MOV	R4,[R0+#0CH]
	ADD	R4,#01h
	MOV	[R0+#0CH],R4
	SUB	R4,#01h
	MOVB	RL7,[R4]
; _doprint.c  225			} while( 0 );
_48:
; _doprint.c  226	
; _doprint.c  227			if( ch == 'c' || ch == 'd' || ch == 'i' || ch == 'o' ||
; _doprint.c  228			    ch == 'x' || ch == 'X' || ch == 'u' )
	CMPB	RL7,#063h
	JMPR	cc_EQ,_54
	CMPB	RL7,#064h
	JMPR	cc_EQ,_54
	CMPB	RL7,#069h
	JMPR	cc_EQ,_54
	CMPB	RL7,#06Fh
	JMPR	cc_EQ,_54
	CMPB	RL7,#078h
	JMPR	cc_EQ,_54
	CMPB	RL7,#058h
	JMPR	cc_EQ,_54
	CMPB	RL7,#075h
	JMPR	cc_NE,_55
_54:
; _doprint.c  229			{
; _doprint.c  230				/* character                    */
; _doprint.c  231				/* signed decimal integer       */
; _doprint.c  232				/* unsigned octal int           */
; _doprint.c  233				/* unsigned hexadecimal int     */
; _doprint.c  234				/* unsigned decimal int         */
; _doprint.c  235				/* int, single character        */
; _doprint.c  236	#ifndef SMALL
; _doprint.c  237				_putnumber( min, max, ch, format,
; _doprint.c  238					    (format & 0x03) == 0x02 ?
; _doprint.c  239						(void *)&va_arg( ap, long ) :
; _doprint.c  240						(void *)&va_arg( ap, int ),
; _doprint.c  241					    fout, &characters );
	MOV	R4,R0
	MOV	[-R0],R4
	MOV	R4,[R0+#012H]
	MOV	[-R0],R4
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#02h
	JMPR	cc_NE,_80
_81:
	MOV	R4,[R0+#012H]
	MOV	R2,#04h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
	JMPR	cc_UC,_82
_80:
	MOV	R4,[R0+#012H]
	MOV	R2,#02h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
_82:
	MOV	[-R0],R5
	MOV	R12,R8
	MOV	R13,R9
	MOVBZ	R14,RL7
	MOVBZ	R15,RL6
	CALLS	SEG __putnumber,__putnumber
	ADD	R0,#06h
; _doprint.c  242	#else
; _doprint.c  243				_putnumber( ch, format,
; _doprint.c  244					    (format & 0x03) == 0x02 ?
; _doprint.c  245						(void *)&va_arg( ap, long ) :
; _doprint.c  246						(void *)&va_arg( ap, int ),
; _doprint.c  247					    fout, &characters );
; _doprint.c  248	#endif
; _doprint.c  249			}
	JMPA	cc_UC,_18
_55:
; _doprint.c  250			else if( ch == 's' )
	CMPB	RL7,#073h
	JMPR	cc_NE,_56
; _doprint.c  251			{
; _doprint.c  252				/* string */
; _doprint.c  253	#ifndef SMALL
; _doprint.c  254				_putstring(     format, min, max, va_arg( ap, char * ),
; _doprint.c  255						fout, &characters );
	MOV	R4,R0
	MOV	[-R0],R4
	MOV	R4,[R0+#012H]
	MOV	[-R0],R4
	MOVBZ	R12,RL6
	MOV	R13,R8
	MOV	R14,R9
	MOV	R4,[R0+#012H]
	MOV	R2,#02h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
	MOV	R15,[R5]
	CALLS	SEG __putstring,__putstring
	ADD	R0,#04h
; _doprint.c  256	#else
; _doprint.c  257				_putstring(     va_arg( ap, char * ), fout, &characters );
; _doprint.c  258	#endif
; _doprint.c  259			}
	JMPA	cc_UC,_17
_56:
; _doprint.c  260	
; _doprint.c  261			else if( ch == 'f' || ch == 'e' || ch == 'E' ||
; _doprint.c  262				 ch == 'g' || ch == 'G' )
	CMPB	RL7,#066h
	JMPR	cc_EQ,_60
	CMPB	RL7,#065h
	JMPR	cc_EQ,_60
	CMPB	RL7,#045h
	JMPR	cc_EQ,_60
	CMPB	RL7,#067h
	JMPR	cc_EQ,_60
	CMPB	RL7,#047h
	JMPR	cc_NE,_62
_60:
; _doprint.c  263			{
; _doprint.c  264				/* floating point       */
; _doprint.c  265	#ifdef LARGE            /* Only supported on 'LARGE' formatter */
; _doprint.c  266				if( !mxflg )
	MOVB	RL4,[R0+#03H]
	JMPR	cc_NZ,_61
; _doprint.c  267					max = 6;
	MOV	R9,#06h
_61:
; _doprint.c  268				_doflt( min, max, ch, format, (double *)&va_arg( ap, double ),
; _doprint.c  269					fout, &characters );
	MOV	R4,R0
	MOV	[-R0],R4
	MOV	R4,[R0+#012H]
	MOV	[-R0],R4
	MOV	R4,[R0+#012H]
	MOV	R2,#08h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
	MOV	[-R0],R5
	MOV	R12,R8
	MOV	R13,R9
	MOVBZ	R14,RL7
	MOVBZ	R15,RL6
	CALLS	SEG __doflt,__doflt
	ADD	R0,#06h
; _doprint.c  270	#else
; _doprint.c  271				/* Just print we do not support floating point values */
; _doprint.c  272				_fputs( "<no floats>", fout, &characters );
; _doprint.c  273				/* select next argument */
; _doprint.c  274				va_arg( ap, double );
; _doprint.c  275	#endif
; _doprint.c  276			}
	JMPA	cc_UC,_16
_62:
; _doprint.c  277	
; _doprint.c  278			else if( ch == 'p' )
	CMPB	RL7,#070h
	JMPA	cc_NE,_76
; _doprint.c  279			{
; _doprint.c  280	#if _MODEL == 't' || _MODEL == 's'
; _doprint.c  281				/* In tiny or small model, a near pointer       */
; _doprint.c  282				/* Print as '<near>%04X'                        */
; _doprint.c  283				if ( !(format & 0x03) )
	MOVB	RL4,#03h
	ANDB	RL4,RL6
	JMPR	cc_NZ,_63
; _doprint.c  284				{
; _doprint.c  285					format |= 0x1;  /* Near pointer */
	ORB	RL6,#01h
; _doprint.c  286				}
_63:
; _doprint.c  287	#else   /* _MODEL == 'm' || _MODEL == 'l' */
; _doprint.c  288				/* In Medium and Large model, always a far pointer */
; _doprint.c  289				/* Print as '<far>%02X:%04X'    */
; _doprint.c  290				if ( !(format & 0x03) )
; _doprint.c  291				{
; _doprint.c  292					format |= 0x2;  /* Far pointer */
; _doprint.c  293				}
; _doprint.c  294	#endif
; _doprint.c  295				/* At this point, (format & 0x03) represents :  */
; _doprint.c  296				/*      0x01 -> Near pointer (%p or %hp)        */
; _doprint.c  297				/*      0x02 -> Far pointer  (%p or %lp)        */
; _doprint.c  298				/*      0x03 -> Huge pointer (%Lp)              */
; _doprint.c  299	
; _doprint.c  300	#ifndef SMALL
; _doprint.c  301				/* misuse 'max' */
; _doprint.c  302				max = (format & 0x03) == 0x01 ? 10 : (format & 0x03) == 0x02 ? 14 : 13;
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#01h
	JMPR	cc_NE,_83
_84:
	MOV	R9,#0Ah
	JMPR	cc_UC,_85
_83:
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#02h
	JMPR	cc_NE,_86
_87:
	MOV	R9,#0Eh
	JMPR	cc_UC,_88
_86:
	MOV	R9,#0Dh
_88:
_85:
; _doprint.c  303	
; _doprint.c  304				if( !(format & 0x40) )
	MOVB	RL4,#040h
	ANDB	RL4,RL6
	JMPR	cc_NZ,_66
; _doprint.c  305				{       /* right alignment ?    */
; _doprint.c  306					for( ; min>max; --min )
	JMPR	cc_UC,_65
_64:
; _doprint.c  307					{
; _doprint.c  308						characters++;
	MOV	R4,[R0]
	ADD	R4,#01h
	MOV	[R0],R4
; _doprint.c  309						fputc( ' ', fout );
	MOV	R12,#020h
	MOV	R13,[R0+#010H]
	CALLS	SEG _fputc,_fputc
	SUB	R8,#01h
_65:
	CMP	R8,R9
	JMPR	cc_SGT,_64
; _doprint.c  310					}
; _doprint.c  311				}
_66:
; _doprint.c  312	#endif
; _doprint.c  313				_fputs( (format & 0x03) == 0x01 ? "<near>" :
; _doprint.c  314					(format & 0x03) == 0x02 ? "<far>" :
; _doprint.c  315								  "<huge>",
; _doprint.c  316					fout, &characters
; _doprint.c  317				      );
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#01h
	JMPR	cc_NE,_89
_90:
	MOV	R12,#_9
	JMPR	cc_UC,_91
_89:
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#02h
	JMPR	cc_NE,_92
_93:
	MOV	R12,#_10
	JMPR	cc_UC,_94
_92:
	MOV	R12,#_11
_94:
_91:
	MOV	R13,[R0+#010H]
	MOV	R14,R0
	CALLS	SEG __fputs,__fputs
; _doprint.c  318				{
; _doprint.c  319					unsigned char cc;
; _doprint.c  320					/* <near>XXXX, <far>XXXX:XXXX, <huge>XX:XXXX */
; _doprint.c  321					if ( (format & 0x03) != 0x01 )
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#01h
	JMPR	cc_EQ,_69
; _doprint.c  322					{
; _doprint.c  323	#ifdef FIX_BFWD
; _doprint.c  324	#pragma fix_byte_write
; _doprint.c  325	#endif
; _doprint.c  326						for( cc = ((format & 0x03) == 0x03 ? 3 : 4);
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#03h
	JMPR	cc_NE,_95
_96:
	MOVB	RL4,#03h
	JMPR	cc_UC,_97
_95:
	MOVB	RL4,#04h
_97:
	MOVB	[R0+#02H],RL4
	JMPR	cc_UC,_68
_67:
; _doprint.c  327						     cc-- > 2;
; _doprint.c  328						   )
; _doprint.c  329						{       /* (far) cc = 3, cc = 2 */
; _doprint.c  330							_printhex( (*(char **)ap)[cc],
; _doprint.c  331								   fout, &characters );
	MOV	R4,[R0+#0EH]
	MOV	R5,[R4]
	MOVB	RL4,[R0+#02H]
	MOVBZ	R4,RL4
	ADD	R5,R4
	MOVB	RL4,[R5]
	MOVBS	R12,RL4
	MOV	R13,[R0+#010H]
	MOV	R14,R0
	CALLS	SEG __printhex,__printhex
_68:
	MOVB	RL4,[R0+#02H]
	SUBB	RL4,#01h
	MOVB	[R0+#02H],RL4
	ADDB	RL4,#01h
	CMPB	RL4,#02h
	JMPR	cc_UGT,_67
; _doprint.c  332						}
; _doprint.c  333	#ifdef FIX_BFWD
; _doprint.c  334	#pragma nofix_byte_write
; _doprint.c  335	#endif
; _doprint.c  336	
; _doprint.c  337						characters++;
	MOV	R4,[R0]
	ADD	R4,#01h
	MOV	[R0],R4
; _doprint.c  338						fputc( ':', fout );
	MOV	R12,#03Ah
	MOV	R13,[R0+#010H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  339					}
_69:
; _doprint.c  340	
; _doprint.c  341					for( cc = 2; cc-- != 0; )
	MOVB	RL4,#02h
	MOVB	[R0+#02H],RL4
	JMPR	cc_UC,_71
_70:
; _doprint.c  342					{       /* cc = 1, cc = 0 */
; _doprint.c  343						_printhex( (*(char **)ap)[cc], fout, &characters );
	MOV	R4,[R0+#0EH]
	MOV	R5,[R4]
	MOVB	RL4,[R0+#02H]
	MOVBZ	R4,RL4
	ADD	R5,R4
	MOVB	RL4,[R5]
	MOVBS	R12,RL4
	MOV	R13,[R0+#010H]
	MOV	R14,R0
	CALLS	SEG __printhex,__printhex
_71:
	MOVB	RL4,[R0+#02H]
	SUBB	RL4,#01h
	MOVB	[R0+#02H],RL4
	ADDB	RL4,#01h
	JMPR	cc_NZ,_70
; _doprint.c  344					};
; _doprint.c  345				}
; _doprint.c  346	#ifndef SMALL
; _doprint.c  347				for( ; min>max; --min )
	JMPR	cc_UC,_73
_72:
; _doprint.c  348				{
; _doprint.c  349					characters++;
	MOV	R4,[R0]
	ADD	R4,#01h
	MOV	[R0],R4
; _doprint.c  350					fputc( ' ', fout );
	MOV	R12,#020h
	MOV	R13,[R0+#010H]
	CALLS	SEG _fputc,_fputc
	SUB	R8,#01h
_73:
	CMP	R8,R9
	JMPR	cc_SGT,_72
; _doprint.c  351				}
; _doprint.c  352	#endif
; _doprint.c  353	
; _doprint.c  354	#if _MODEL == 't'
; _doprint.c  355				va_arg( ap, void * );   /* select next argument */
; _doprint.c  356	#else
; _doprint.c  357				if( (format & 0x03) == 0x01 )
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#01h
	JMPR	cc_NE,_74
; _doprint.c  358					va_arg( ap, near void * );
	MOV	R4,[R0+#0EH]
	MOV	R5,[R4]
	ADD	R5,#02h
	MOV	[R4],R5
	JMPA	cc_UC,_15
_74:
; _doprint.c  359				else if( (format & 0x03) == 0x02 )
	MOVBZ	R4,RL6
	AND	R4,#03h
	CMP	R4,#02h
	JMPR	cc_NE,_75
; _doprint.c  360					va_arg( ap, far void * );
	MOV	R4,[R0+#0EH]
	MOV	R5,[R4]
	ADD	R5,#04h
	MOV	[R4],R5
	JMPA	cc_UC,_14
_75:
; _doprint.c  361				else
; _doprint.c  362					va_arg( ap, huge void * );
	MOV	R4,[R0+#0EH]
	MOV	R5,[R4]
	ADD	R5,#04h
	MOV	[R4],R5
; _doprint.c  363	#endif
; _doprint.c  364			}
	JMPA	cc_UC,_13
_76:
; _doprint.c  365	
; _doprint.c  366			else if( ch == 'n' )
	CMPB	RL7,#06Eh
	JMPR	cc_EQ,_77
; _doprint.c  367			{
; _doprint.c  368				*(va_arg( ap, int * )) = characters;
; _doprint.c  369			}
; _doprint.c  370			else
; _doprint.c  371			{
; _doprint.c  372				errno = ERR_FORMAT;     /* illegal format string */
	MOV	R4,#01h
	MOV	_errno,R4
; _doprint.c  373				return( characters );
	MOV	R4,[R0]
	JMPR	cc_UC,_79
_77:
	MOV	R4,[R0+#0EH]
	MOV	R2,#02h
	MOV	R5,[R4]
	ADD	R2,R5
	MOV	[R4],R2
	MOV	R4,[R5]
	MOV	[R4],[R0]
	JMPA	cc_UC,_12
_78:
	MOV	R4,[R0]
; _doprint.c  374			}
; _doprint.c  375		}
; _doprint.c  376	}
_79:
	ADD	R0,#04h
	MOV	R6,[R0+]
	MOV	R7,[R0+]
	MOV	R8,[R0+]
	MOV	R9,[R0+]
	ADD	R0,#06h
	RETS
__doprint	ENDP
; _doprint.c  377	
; _doprint.c  378	/* prints a string to the output                                          */
; _doprint.c  379	/* when 'min' > 'max', the result is undefined                            */
; _doprint.c  380	/* when 'left' != 0, left alignment is done                               */
; _doprint.c  381	/* when min=0, and max=0, strings are printed normal                      */
; _doprint.c  382	/* length of the strings are supposed to be SMALLer than 30000 characters */
; _doprint.c  383	#ifndef SMALL   /* For 'SMALL', _fputs() is called instead of _putstring  */
; _doprint.c  384	static void
; _doprint.c  385	_putstring(     unsigned char format, register int min, register int max,
; _doprint.c  386			register char *str, FILE *fout, unsigned int *characters )
; _doprint.c  387	{
; length = R9 (automatic)
__putstring	PROC	FAR
; format = offset 8 (parameter: R12 pushed)
; min = R8 (parameter: R13 copied)
; max = R7 (parameter: R14 copied)
; str = R6 (parameter: R15 copied)
; fout = offset 10 (parameter)
; characters = offset 12 (parameter)
; Stack: 14, CSE: 0 offset 0
	MOV	[-R0],R12
	MOV	[-R0],R9
	MOV	[-R0],R8
	MOV	[-R0],R7
	MOV	[-R0],R6
	MOV	R6,R15
	MOV	R7,R14
	MOV	R8,R13
; _doprint.c  388		register int length = 0;
; _doprint.c  389	
; _doprint.c  390		if( !max )
	CMP	R7,#00h
	JMPR	cc_NZ,_109
; _doprint.c  391			max = 30000;
	MOV	R7,#07530h
_109:
; _doprint.c  392	
; _doprint.c  393		length = strlen( str );
	MOV	R12,R6
	CALLS	SEG _strlen,_strlen
	MOV	R9,R4
; _doprint.c  394	
; _doprint.c  395		if( !(format & 0x40) )          /* right alignment ? */
	MOVB	RL4,[R0+#08H]
	ANDB	RL4,#040h
	JMPR	cc_NZ,_116
; _doprint.c  396		{
; _doprint.c  397			for( ; min>length || min>max; --min )
	JMPR	cc_UC,_112
_111:
; _doprint.c  398			{
; _doprint.c  399				(*characters)++;
	MOV	R4,[R0+#0CH]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  400				fputc( ' ', fout );
	MOV	R12,#020h
	MOV	R13,[R0+#0AH]
	CALLS	SEG _fputc,_fputc
	SUB	R8,#01h
_112:
	CMP	R8,R9
	JMPR	cc_SGT,_111
	CMP	R8,R7
	JMPR	cc_SGT,_111
; _doprint.c  401			}
; _doprint.c  402		}
; _doprint.c  403	
; _doprint.c  404		while( max-- && *str )          /* print string */
	JMPR	cc_UC,_116
_113:
; _doprint.c  405		{
; _doprint.c  406			(*characters)++;
	MOV	R4,[R0+#0CH]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  407			fputc( *str++, fout );
	MOVB	RL4,[R6+]
	MOVBS	R12,RL4
	MOV	R13,[R0+#0AH]
	CALLS	SEG _fputc,_fputc
; _doprint.c  408			if( min )
	CMP	R8,#00h
	JMPR	cc_Z,_116
; _doprint.c  409				min--;  /* min will contain the minimum number  */
	SUB	R8,#01h
_116:
	MOV	R4,R7
	SUB	R7,#01h
	CMP	R4,#00h
	JMPR	cc_Z,_119
	MOVB	RL4,[R6]
	JMPR	cc_NZ,_113
; _doprint.c  410					/* of characters to print afterwards    */
; _doprint.c  411		}
; _doprint.c  412	
; _doprint.c  413		while( min-- )
	JMPR	cc_UC,_119
_117:
; _doprint.c  414		{
; _doprint.c  415			(*characters)++;
	MOV	R4,[R0+#0CH]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  416			fputc( ' ', fout );             /* padding spaces */
	MOV	R12,#020h
	MOV	R13,[R0+#0AH]
	CALLS	SEG _fputc,_fputc
_119:
	MOV	R4,R8
	SUB	R8,#01h
	CMP	R4,#00h
	JMPR	cc_NZ,_117
; _doprint.c  417		};
; _doprint.c  418	}
	MOV	R6,[R0+]
	MOV	R7,[R0+]
	MOV	R8,[R0+]
	MOV	R9,[R0+]
	ADD	R0,#02h
	RETS
__putstring	ENDP
; _doprint.c  419	#endif  /* SMALL */
; _doprint.c  420	
; _doprint.c  421	static void
; _doprint.c  422	#ifndef SMALL
; _doprint.c  423	_putnumber(     int min, int max, unsigned char ch, unsigned char format,
; _doprint.c  424			void *pvalue, FILE *fout, unsigned int *characters )
; _doprint.c  425	#else
; _doprint.c  426	_putnumber(     unsigned char ch, unsigned char format, void *pvalue,
; _doprint.c  427			FILE *fout, unsigned int *characters )
; _doprint.c  428	#endif
; _doprint.c  429	{
; vsign = R6 (automatic)
; length = R7 (automatic)
; value = R8 - R9 (automatic)
; buf = offset 0 (automatic)
; buffer = offset 14 (automatic)
__putnumber	PROC	FAR
; min = offset 24 (parameter: R12 pushed)
; max = offset 26 (parameter: R13 pushed)
; ch = offset 28 (parameter: R14 pushed)
; format = offset 30 (parameter: R15 pushed)
; pvalue = offset 32 (parameter)
; fout = offset 34 (parameter)
; characters = offset 36 (parameter)
; Stack: 38, CSE: 0 offset 0
	MOV	[-R0],R15
	MOV	[-R0],R14
	MOV	[-R0],R13
	MOV	[-R0],R12
	MOV	[-R0],R9
	MOV	[-R0],R8
	MOV	[-R0],R7
	MOV	[-R0],R6
	SUB	R0,#010h
; _doprint.c  430		char buf[13];   /* room to print long value in  */
; _doprint.c  431		register char *buffer;  /* help variable        */
; _doprint.c  432	
; _doprint.c  433		register long value = 0;
	MOV	R8,#00h
	MOV	R9,#00h
; _doprint.c  434	
; _doprint.c  435	#ifndef SMALL
; _doprint.c  436		register char length=0; /* length needed to print value */
; _doprint.c  437	#endif
; _doprint.c  438	
; _doprint.c  439		register unsigned char vsign;   /* sign of the value    */
; _doprint.c  440	
; _doprint.c  441		if( !(format & 0x02) )          /* 'h' or default, same as -->  */
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#02h
	JMPR	cc_NZ,_173
; _doprint.c  442						/* (!(format & 0x03) ||         */
; _doprint.c  443						/* (format & 0x03) == 0x01)     */
; _doprint.c  444		{       /* short value is the same as int       */
; _doprint.c  445			value = *(int *)pvalue;
	MOV	R4,[R0+#020H]
	MOV	R5,[R4]
	MOV	R8,R5
	MOV	R9,R8
	ASHR	R9,#0Fh
; _doprint.c  446			if( ch != 'd' && ch != 'i' )    /* not a signed integer ? */
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#064h
	JMPR	cc_EQ,_177
	CMPB	RL4,#069h
	JMPR	cc_EQ,_177
; _doprint.c  447				value &= 0xffff;        /* truncate to positive   */
	AND	R8,#0FFFFh
	AND	R9,#00h
; _doprint.c  448							/* integer */
; _doprint.c  449		}
	JMPR	cc_UC,_177
_173:
; _doprint.c  450		else if( (format & 0x03) == 0x02 )      /* 'l'  */
	MOVB	RL4,[R0+#01EH]
	MOVBZ	R4,RL4
	AND	R4,#03h
	CMP	R4,#02h
	JMPR	cc_NE,_177
; _doprint.c  451		{
; _doprint.c  452			value = *(long *)pvalue;
	MOV	R4,[R0+#020H]
	MOV	R8,[R4+]
	MOV	R9,[R4]
; _doprint.c  453		}
; _doprint.c  454		;
_177:
; _doprint.c  455	
; _doprint.c  456		vsign = 0;      /* 0 - positive value, otherwise negative value */
	MOVB	RL6,#00h
; _doprint.c  457	
; _doprint.c  458		if( ch == 'c' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#063h
	JMPR	cc_NE,_178
; _doprint.c  459		{
; _doprint.c  460			buf[0] = value;
	MOV	R5,R8
	MOVB	[R0],RL5
; _doprint.c  461			buf[1] = '\0';
	MOVB	RL3,#00h
	MOVB	[R0+#01H],RL3
; _doprint.c  462		}
	JMPA	cc_UC,_225
_178:
; _doprint.c  463		else if( ch == 'd' || ch == 'i' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#064h
	JMPR	cc_EQ,_179
	CMPB	RL4,#069h
	JMPR	cc_NE,_180
_179:
; _doprint.c  464		{
; _doprint.c  465			if( value < 0 )
	CMP	R9,#00h
	JMPR	cc_SGT,_182
	JMPR	cc_SLT,_226
	CMP	R8,#00h
	JMPR	cc_UGE,_182
_226:
; _doprint.c  466			{
; _doprint.c  467				vsign = '-';
	MOVB	RL6,#02Dh
; _doprint.c  468				value = -value;
	MOV	R4,R8
	MOV	R5,R9
	NEG	R4
	ADDC	R5,#00h
	NEG	R5
	MOV	R8,R4
	MOV	R9,R5
; _doprint.c  469			}
; _doprint.c  470			goto unsignedint;
	JMPR	cc_UC,_182
; _doprint.c  471		}
_180:
; _doprint.c  472		else if( ch == 'u' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#075h
	JMPA	cc_NE,_199
; _doprint.c  473		{
; _doprint.c  474			unsignedint:
_182:
; _doprint.c  475	
; _doprint.c  476			_ltoa( buf, value, 10 );        /* convert to ascii     */
	MOV	R12,R0
	MOV	R13,R8
	MOV	R14,R9
	MOV	R15,#0Ah
	CALLS	SEG __ltoa,__ltoa
; _doprint.c  477	
; _doprint.c  478	#ifndef SMALL
; _doprint.c  479			length = strlen( buf );
	MOV	R12,R0
	CALLS	SEG _strlen,_strlen
	MOVB	RL7,RL4
; _doprint.c  480	
; _doprint.c  481			if( !vsign )
	CMPB	RL6,#00h
	JMPR	cc_NZ,_186
; _doprint.c  482			{
; _doprint.c  483				if( (format & 0x0C) == 0x04 )   /* sign always  */
	MOVB	RL4,[R0+#01EH]
	MOVBZ	R1,RL4
	AND	R1,#0Ch
	CMP	R1,#04h
	JMPR	cc_NE,_183
; _doprint.c  484					vsign = '+';
	MOVB	RL6,#02Bh
	JMPR	cc_UC,_186
_183:
; _doprint.c  485				else if( (format & 0x0C) == 0x08 ) /* sign or space */
	CMP	R1,#08h
	JMPR	cc_NE,_186
; _doprint.c  486					vsign = ' ';
	MOVB	RL6,#020h
; _doprint.c  487			}
_186:
; _doprint.c  488	
; _doprint.c  489			if( vsign )
	CMPB	RL6,#00h
	JMPR	cc_Z,_188
; _doprint.c  490			{
; _doprint.c  491				if( min )
	MOV	R4,[R0+#018H]
	JMPR	cc_Z,_188
; _doprint.c  492					--min;
	SUB	R4,#01h
	MOV	[R0+#018H],R4
; _doprint.c  493			}
_188:
; _doprint.c  494	
; _doprint.c  495			if( vsign && (format & 0x60) )  /* ( (format & 0x20) || */
	CMPB	RL6,#00h
	JMPR	cc_Z,_190
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#060h
	JMPR	cc_Z,_190
; _doprint.c  496			{                               /* (format & 0x40) )    */
; _doprint.c  497				(*characters)++;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  498				fputc( vsign, fout );
	MOVBZ	R12,RL6
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  499				vsign = 0;
	MOVB	RL6,#00h
; _doprint.c  500			}
_190:
; _doprint.c  501	
; _doprint.c  502			if( !(format & 0x40) )  /* right alignment ? */
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#040h
	JMPR	cc_NZ,_194
; _doprint.c  503			{
; _doprint.c  504				while( (min > max) && (min > length) )
	JMPR	cc_UC,_192
_191:
; _doprint.c  505				{
; _doprint.c  506					(*characters)++;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  507					fputc( (format & 0x20) ? '0' : ' ', fout );
	MOVB	RL4,[R0+#01EH]
	MOVBZ	R4,RL4
	AND	R4,#020h
	JMPR	cc_Z,_227
_228:
	MOV	R12,#030h
	JMPR	cc_UC,_229
_227:
	MOV	R12,#020h
_229:
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  508					min--;
	MOV	R4,[R0+#018H]
	SUB	R4,#01h
	MOV	[R0+#018H],R4
_192:
	MOV	R4,[R0+#018H]
	MOV	R5,[R0+#01AH]
	CMP	R4,R5
	JMPR	cc_SLE,_194
	MOVBS	R2,RL7
	CMP	R4,R2
	JMPR	cc_SGT,_191
; _doprint.c  509				}
; _doprint.c  510			}
_194:
; _doprint.c  511	
; _doprint.c  512	#endif
; _doprint.c  513	
; _doprint.c  514			if( vsign )
	CMPB	RL6,#00h
	JMPR	cc_Z,_198
; _doprint.c  515			{
; _doprint.c  516				(*characters)++;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  517				fputc( vsign, fout );
	MOVBZ	R12,RL6
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  518			}
; _doprint.c  519	
; _doprint.c  520	#ifndef SMALL
; _doprint.c  521			while( max-- > length )
	JMPR	cc_UC,_198
_195:
; _doprint.c  522			{
; _doprint.c  523				(*characters)++;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  524				fputc( '0', fout );
	MOV	R12,#030h
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  525				if( min )
	MOV	R4,[R0+#018H]
	JMPR	cc_Z,_198
; _doprint.c  526					min--;
	SUB	R4,#01h
	MOV	[R0+#018H],R4
_198:
	MOV	R4,[R0+#01AH]
	SUB	R4,#01h
	MOV	[R0+#01AH],R4
	ADD	R4,#01h
	MOVBS	R5,RL7
	CMP	R4,R5
	JMPR	cc_SGT,_195
; _doprint.c  527			}
; _doprint.c  528	#endif
; _doprint.c  529		}
	JMPA	cc_UC,_225
_199:
; _doprint.c  530		else if( ch == 'o' || ch == 'x' || ch == 'X' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#06Fh
	JMPR	cc_EQ,_201
	CMPB	RL4,#078h
	JMPR	cc_EQ,_201
	CMPB	RL4,#058h
	JMPA	cc_NE,_225
_201:
; _doprint.c  531		{
; _doprint.c  532	
; _doprint.c  533			_ltoa( buf, value, ch == 'o' ? 8 : 16 );
	MOV	R12,R0
	MOV	R13,R8
	MOV	R14,R9
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#06Fh
	JMPR	cc_NE,_230
_231:
	MOVB	RL4,#08h
	JMPR	cc_UC,_232
_230:
	MOVB	RL4,#010h
_232:
	MOVBS	R15,RL4
	CALLS	SEG __ltoa,__ltoa
; _doprint.c  534	
; _doprint.c  535			if( ch == 'x' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#078h
	JMPR	cc_NE,_206
; _doprint.c  536			{
; _doprint.c  537				/* convert string to lowercase  */
; _doprint.c  538				for( buffer = buf; *buffer; ++buffer )
	MOV	R4,R0
	MOV	[R0+#0EH],R4
	JMPR	cc_UC,_205
_202:
; _doprint.c  539				{       /* do not use 'tolower' */
; _doprint.c  540					if( *buffer >= 'A' && *buffer <= 'Z' )
	MOV	R4,[R0+#0EH]
	MOVB	RL5,[R4]
	CMPB	RL5,#041h
	JMPR	cc_SLT,_204
	MOVB	RL5,[R4]
	CMPB	RL5,#05Ah
	JMPR	cc_SGT,_204
; _doprint.c  541						*buffer += 'a' - 'A';
	MOVB	RL5,[R4]
	ADDB	RL5,#020h
	MOVB	[R4],RL5
_204:
	MOV	R4,[R0+#0EH]
	ADD	R4,#01h
	MOV	[R0+#0EH],R4
_205:
	MOV	R4,[R0+#0EH]
	MOVB	RL5,[R4]
	JMPR	cc_NZ,_202
; _doprint.c  542				}
; _doprint.c  543			}
_206:
; _doprint.c  544	
; _doprint.c  545	#ifndef SMALL
; _doprint.c  546			length = strlen( buf );
	MOV	R12,R0
	CALLS	SEG _strlen,_strlen
	MOVB	RL7,RL4
; _doprint.c  547	
; _doprint.c  548			if( ! value )
	MOV	R4,R8
	OR	R4,R9
	JMPR	cc_NZ,_207
; _doprint.c  549				format &= 0xEF; /* clear alternate when value is '0' */
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#0EFh
	MOVB	[R0+#01EH],RL4
_207:
; _doprint.c  550	
; _doprint.c  551			if( (format & 0x10) )   /* alternate */
	MOVB	RL4,[R0+#01EH]
	MOVBZ	R4,RL4
	AND	R4,#010h
	JMPR	cc_Z,_213
; _doprint.c  552			{
; _doprint.c  553				if( format & 0x20 )     /* alternate and filling from */
	MOVB	RL4,[R0+#01EH]
	MOVBZ	R4,RL4
	AND	R4,#020h
	JMPR	cc_Z,_209
; _doprint.c  554				{                       /* the left with zeros  */
; _doprint.c  555					if( ch != 'o' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#06Fh
	JMPR	cc_EQ,_208
; _doprint.c  556					{
; _doprint.c  557						*characters += 2;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#02h
	MOV	[R4],R5
; _doprint.c  558						fputc( '0', fout );     /* leading 0 */
	MOV	R12,#030h
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  559						fputc( ch, fout );
	MOVB	RL4,[R0+#01CH]
	MOVBZ	R12,RL4
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  560					}
_208:
; _doprint.c  561					format &= 0xEF; /* clear alternate */
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#0EFh
	MOVB	[R0+#01EH],RL4
; _doprint.c  562				}
_209:
; _doprint.c  563	
; _doprint.c  564				if( ch == 'o' )
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#06Fh
	JMPR	cc_NE,_213
; _doprint.c  565				{
; _doprint.c  566					if( max )
	MOV	R4,[R0+#01AH]
	JMPR	cc_Z,_210
; _doprint.c  567						max++;
	ADD	R4,#01h
	MOV	[R0+#01AH],R4
_210:
; _doprint.c  568					if( max <= length )
	MOV	R4,[R0+#01AH]
	MOVBS	R5,RL7
	CMP	R4,R5
	JMPR	cc_SGT,_213
; _doprint.c  569						max = length+1;
	MOVBS	R5,RL7
	ADD	R5,#01h
	MOV	[R0+#01AH],R5
; _doprint.c  570				}
; _doprint.c  571			}
_213:
; _doprint.c  572	
; _doprint.c  573			if( !(format & 0x40) )          /* right alignment      */
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#040h
	JMPR	cc_NZ,_217
; _doprint.c  574			{
; _doprint.c  575				while( (min > max) && (min > length) )
	JMPR	cc_UC,_215
_214:
; _doprint.c  576				{
; _doprint.c  577					(*characters)++;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  578					fputc( (format & 0x20) ? '0' : ' ', fout );
	MOVB	RL4,[R0+#01EH]
	MOVBZ	R4,RL4
	AND	R4,#020h
	JMPR	cc_Z,_233
_234:
	MOV	R12,#030h
	JMPR	cc_UC,_235
_233:
	MOV	R12,#020h
_235:
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  579					min--;
	MOV	R4,[R0+#018H]
	SUB	R4,#01h
	MOV	[R0+#018H],R4
_215:
	MOV	R4,[R0+#018H]
	MOV	R5,[R0+#01AH]
	CMP	R4,R5
	JMPR	cc_SLE,_217
	MOVBS	R2,RL7
	CMP	R4,R2
	JMPR	cc_SGT,_214
; _doprint.c  580				}
; _doprint.c  581			}
_217:
; _doprint.c  582	
; _doprint.c  583			if( (format & 0x10) && (ch != 'o') )
	MOVB	RL4,[R0+#01EH]
	ANDB	RL4,#010h
	JMPR	cc_Z,_222
	MOVB	RL4,[R0+#01CH]
	CMPB	RL4,#06Fh
	JMPR	cc_EQ,_222
; _doprint.c  584			{
; _doprint.c  585				*characters += 2;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#02h
	MOV	[R4],R5
; _doprint.c  586				fputc( '0', fout );     /* leading 0 */
	MOV	R12,#030h
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  587				fputc( ch, fout );      /* and 'x' */
	MOVB	RL4,[R0+#01CH]
	MOVBZ	R12,RL4
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  588			}
; _doprint.c  589	
; _doprint.c  590			while( max-- > length )
	JMPR	cc_UC,_222
_218:
; _doprint.c  591			{
; _doprint.c  592				(*characters)++;
	MOV	R4,[R0+#024H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  593				fputc( '0', fout );
	MOV	R12,#030h
	MOV	R13,[R0+#022H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  594				if( min )
	MOV	R4,[R0+#018H]
	JMPR	cc_Z,_222
; _doprint.c  595					min--;
	SUB	R4,#01h
	MOV	[R0+#018H],R4
_222:
	MOV	R4,[R0+#01AH]
	SUB	R4,#01h
	MOV	[R0+#01AH],R4
	ADD	R4,#01h
	MOVBS	R5,RL7
	CMP	R4,R5
	JMPR	cc_SGT,_218
; _doprint.c  596			}
; _doprint.c  597	#endif
; _doprint.c  598		}
; _doprint.c  599	
; _doprint.c  600	#ifndef SMALL
; _doprint.c  601		/* now print the ascii value, padded with spaces */
; _doprint.c  602		_putstring( format, min, 0, buf, fout, characters );
_225:
	MOV	R4,[R0+#024H]
	MOV	[-R0],R4
	MOV	R5,[R0+#024H]
	MOV	[-R0],R5
	MOVB	RL4,[R0+#022H]
	MOVBZ	R12,RL4
	MOV	R13,[R0+#01CH]
	MOV	R14,#00h
	MOV	R15,#04h
	ADD	R15,R0
	CALLS	SEG __putstring,__putstring
	ADD	R0,#014h
; _doprint.c  603	#else
; _doprint.c  604		/* now print the ascii value    */
; _doprint.c  605		_putstring( buf, fout, characters );
; _doprint.c  606	#endif
; _doprint.c  607	}
	MOV	R6,[R0+]
	MOV	R7,[R0+]
	MOV	R8,[R0+]
	MOV	R9,[R0+]
	ADD	R0,#08h
	RETS
__putnumber	ENDP
; _doprint.c  608	
; _doprint.c  609	/* print only a string to the output                                    */
; _doprint.c  610	/* When the 'SMALL' formatter is requested, _fputs() is called for      */
; _doprint.c  611	/* _printstring()                                                       */
; _doprint.c  612	static void
; _doprint.c  613	_fputs( char * str, FILE * fout, unsigned int *characters )
; _doprint.c  614	{
__fputs	PROC	FAR
; str = R9 (parameter: R12 copied)
; fout = offset 2 (parameter: R13 pushed)
; characters = offset 4 (parameter: R14 pushed)
; Stack: 6, CSE: 0 offset 0
	MOV	[-R0],R14
	MOV	[-R0],R13
	MOV	[-R0],R9
	MOV	R9,R12
; _doprint.c  615		while( *str )
	JMPR	cc_UC,_237
_236:
; _doprint.c  616		{
; _doprint.c  617			(*characters)++;
	MOV	R4,[R0+#04H]
	MOV	R5,[R4]
	ADD	R5,#01h
	MOV	[R4],R5
; _doprint.c  618			fputc( *str, fout );
	MOVB	RL4,[R9]
	MOVBS	R12,RL4
	MOV	R13,[R0+#02H]
	CALLS	SEG _fputc,_fputc
; _doprint.c  619			str++;
	ADD	R9,#01h
_237:
	MOVB	RL4,[R9]
	JMPR	cc_NZ,_236
; _doprint.c  620		}
; _doprint.c  621	}
	MOV	R9,[R0+]
	ADD	R0,#04h
	RETS
__fputs	ENDP
_DOPRINT_1_PR	ENDS

_DOPRINT_2_CO	SECTION	LDAT WORD PUBLIC 'CROM'
_11	DB	03Ch,068h,075h,067h,065h,03Eh,00h
_9	DB	03Ch,06Eh,065h,061h,072h,03Eh,00h
_10	DB	03Ch,066h,061h,072h,03Eh,00h
_DOPRINT_2_CO	ENDS

C166_US	SECTION	LDAT WORD GLBUSRSTACK 'CUSTACK'
	DS	84
C166_US	ENDS

	EXTERN	_strlen:FAR
	EXTERN	_fputc:FAR
	EXTERN	_errno:WORD
	EXTERN	__ltoa:FAR
	EXTERN	__doflt:FAR
	REGDEF	R0-R15
	END
