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 "ram.h"
|
---|
16 |
|
---|
17 | static int16_t fpsub(int16_t c);
|
---|
18 |
|
---|
19 | /*
|
---|
20 | =============================================================================
|
---|
21 | printf(fmt, args) -- output 'args' according to 'fmt' on CON_DEV
|
---|
22 | =============================================================================
|
---|
23 | */
|
---|
24 |
|
---|
25 | int16_t printf(int8_t *fmt, ...)
|
---|
26 | {
|
---|
27 | register int16_t count;
|
---|
28 | va_list aptr;
|
---|
29 |
|
---|
30 | va_start(aptr, fmt);
|
---|
31 | count = dofmt_(fpsub, fmt, aptr);
|
---|
32 | va_end(aptr);
|
---|
33 | return(count);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /*
|
---|
37 | =============================================================================
|
---|
38 | fpsub(c) -- output 'c' to CON_DEV
|
---|
39 | =============================================================================
|
---|
40 | */
|
---|
41 |
|
---|
42 | static int16_t fpsub(int16_t c)
|
---|
43 | {
|
---|
44 | /* KLUDGE: since we aren't Unix(tm) we prepend a CR to LF's */
|
---|
45 |
|
---|
46 | if (c EQ '\n')
|
---|
47 | BIOS(B_PUTC, CON_DEV, '\r');
|
---|
48 |
|
---|
49 | BIOS(B_PUTC, CON_DEV, c);
|
---|
50 | return(c);
|
---|
51 | }
|
---|
52 |
|
---|