diff options
Diffstat (limited to 'c/libc.s')
| -rw-r--r-- | c/libc.s | 67 |
1 files changed, 51 insertions, 16 deletions
@@ -25,11 +25,11 @@ _getargs: ld c, l ret - ;; void putc(char c /*A*/) + ;; void putc(char c /*A*/) -> stdout via SYS_PUTC _putc: - ld (0xff01), a - ld a, #0x81 - ld (0xff02), a + ld e, a + ld c, #16 ; SYS_PUTC + rst #0x30 ret ;; void puts(const char *s /*DE*/) - write until NUL (no newline) @@ -37,22 +37,22 @@ _puts: 1$: ld a, (de) or a ret z - ld (0xff01), a - ld a, #0x81 - ld (0xff02), a + push de + ld e, a + ld c, #16 ; SYS_PUTC + rst #0x30 + pop de inc de jr 1$ - ;; void nl(void) - CRLF + ;; void nl(void) - CRLF via stdout _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 + ld e, #0x0d + ld c, #16 ; SYS_PUTC + rst #0x30 + ld e, #0x0a + ld c, #16 + rst #0x30 ret ;; unsigned char strlen(const char *s /*DE*/) -> A @@ -132,3 +132,38 @@ _fremove: ld c, #15 ; SYS_REMOVE rst #0x30 ret + + .globl _fork, _exec, _wait, _setin, _setout, _lookup + ;; unsigned char fork(void) -> A (child pid in parent, 0 in child) +_fork: + ld c, #1 ; SYS_FORK + rst #0x30 + ret + ;; void exec(unsigned char id /*A*/) - never returns +_exec: + ld b, a + ld c, #6 ; SYS_EXEC + rst #0x30 + ret + ;; unsigned char wait(void) -> A (reaped pid) +_wait: + ld c, #7 ; SYS_WAIT + rst #0x30 + ret + ;; void setin(unsigned char fd /*A*/) +_setin: + ld b, a + ld c, #17 ; SYS_SETIN + rst #0x30 + ret + ;; void setout(unsigned char fd /*A*/) +_setout: + ld b, a + ld c, #18 ; SYS_SETOUT + rst #0x30 + ret + ;; unsigned char lookup(const char *name /*DE*/) -> A (prog id or $FF) +_lookup: + ld c, #19 ; SYS_LOOKUP + rst #0x30 + ret |
