[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | printf.c -- printf function
|
---|
| 4 | Version 6 -- 1987-08-13 -- D.N. Lynx Crowe
|
---|
| 5 |
|
---|
| 6 | RECOVERED From: Version 5 -- 1987-06-16 -- D.N. Lynx Crowe
|
---|
| 7 |
|
---|
| 8 | "Crufty code" Warning:
|
---|
| 9 | Since this isn't Unix(tm), we prepend a '\r' when we see a '\n'.
|
---|
| 10 | We also return a long, since this is a 32 bit address machine.
|
---|
| 11 | (Well, almost 32 bits. Too big for an Alcyon 16 bit int anyway.)
|
---|
| 12 | =============================================================================
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | #include "stddefs.h"
|
---|
| 16 | #include "biosdefs.h"
|
---|
[bfc0072] | 17 | #include "stdarg.h"
|
---|
[f40a309] | 18 |
|
---|
[7258c6a] | 19 | extern int32_t dofmt_(int16_t (*putsub)(), int8_t *format, va_list args);
|
---|
[f40a309] | 20 |
|
---|
[7258c6a] | 21 | static int16_t fpsub(int16_t c);
|
---|
[df097bf] | 22 |
|
---|
[f40a309] | 23 | /*
|
---|
| 24 | =============================================================================
|
---|
| 25 | printf(fmt, args) -- output 'args' according to 'fmt' on CON_DEV
|
---|
| 26 | =============================================================================
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[7258c6a] | 29 | int32_t printf(int8_t *fmt, ...)
|
---|
[f40a309] | 30 | {
|
---|
[7258c6a] | 31 | register int32_t count;
|
---|
[f40a309] | 32 | va_list aptr;
|
---|
| 33 |
|
---|
[bfc0072] | 34 | va_start(aptr, fmt);
|
---|
[f40a309] | 35 | count = dofmt_(fpsub, fmt, aptr);
|
---|
| 36 | va_end(aptr);
|
---|
| 37 | return(count);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /*
|
---|
| 41 | =============================================================================
|
---|
| 42 | fpsub(c) -- output 'c' to CON_DEV
|
---|
| 43 | =============================================================================
|
---|
| 44 | */
|
---|
| 45 |
|
---|
[7258c6a] | 46 | static int16_t fpsub(int16_t c)
|
---|
[f40a309] | 47 | {
|
---|
| 48 | /* KLUDGE: since we aren't Unix(tm) we prepend a CR to LF's */
|
---|
| 49 |
|
---|
| 50 | if (c EQ '\n')
|
---|
| 51 | BIOS(B_PUTC, CON_DEV, '\r');
|
---|
| 52 |
|
---|
| 53 | BIOS(B_PUTC, CON_DEV, c);
|
---|
| 54 | return(c);
|
---|
| 55 | }
|
---|