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
|
.module libc
.globl _writes, _nl, _readc, _sexit, _getpid
.area _CODE
;; void writes(const char *buf /*DE*/, unsigned char len /*A*/)
_writes:
push hl
push de
push bc
ld b, a
ld c, #3 ; SYS_WRITE
rst #0x30
pop bc
pop de
pop hl
ret
;; void nl(void) - CRLF straight to serial
_nl:
ld a, #0x0d
ld (0xff01), a
ld a, #0x81
ld (0xff02), a
ld a, #0x0a
ld (0xff01), a
ld a, #0x81
ld (0xff02), a
ret
;; unsigned char readc(void) -> A
_readc:
push hl
push de
push bc
ld c, #2 ; SYS_READ
rst #0x30
pop bc
pop de
pop hl
ret
;; void sexit(unsigned char code /*A*/)
_sexit:
ld b, a
ld c, #0 ; SYS_EXIT
rst #0x30
ret
;; unsigned char getpid(void) -> A
_getpid:
push hl
push de
push bc
ld c, #8 ; SYS_GETPID
rst #0x30
pop bc
pop de
pop hl
ret
|