-
Notifications
You must be signed in to change notification settings - Fork 1
/
putchar.c
57 lines (50 loc) · 965 Bytes
/
putchar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "calling.h"
int putchar(int c)
{
#ifdef REGISTER_CALLING
__asm
; putchar routine for CP/M -- sdcccall(1) version
; char to print is in L
push hl
; print char
ld e,l
ld c,#2
call 5
; check for CR
pop hl
ld a, l
cp #10
ret nz ; return if not CR
; after CR always print LF
ld e, #13
ld c, #2
jp 5 ; leave our return address on the stack
__endasm;
#else
__asm
; putchar routine for CP/M -- sdcccall(0) version
; char to print is in (SP+2)
ld hl,#2
add hl,sp
push hl
; print char
ld e,(hl)
ld c,#2
call 5
; check for CR
pop hl
ld a, (hl)
cp #10
ret nz ; return if not CR
; after CR always print LF
ld e, #13
ld c, #2
jp 5 ; leave our return address on the stack
__endasm;
#endif
/* this code is compiled but never used.
* it exists to squelch compiler warnings.
*/
c;
return 0;
}