Add some BIOS bindings, and a zero-terminated print string routine.

This commit is contained in:
David Given 2019-06-24 23:07:17 +02:00
parent 1bd6a9d4fa
commit 97d22973ee
7 changed files with 88 additions and 1 deletions

View file

@ -77,8 +77,8 @@ name led
(.e:{TAIL}={PLATFORMDIR}/libem.a \
{PLATFORMDIR}/libsys.a \
{PLATFORMDIR}/libc.a \
{PLATFORMDIR}/libsys.a \
{PLATFORMDIR}/libem.a \
{PLATFORMDIR}/libsys.a \
{PLATFORMDIR}/libend.a)
linker
end

View file

@ -83,6 +83,9 @@ extern uint8_t cpm_read_random_safe(FCB* fcb);
/* Extends cpm_ramtop over the CCP, for a little extra space. */
extern void cpm_overwrite_ccp(void);
/* Like cpm_printstring, but uses C-style strings terminated with a \0. */
extern void cpm_printstring0(const char* s);
/* 0 */ extern void cpm_warmboot(void);
/* 1 */ extern uint8_t cpm_conin(void);
/* 2 */ extern void cpm_conout(uint8_t b);
@ -126,4 +129,8 @@ extern void cpm_overwrite_ccp(void);
#define cpm_get_user() cpm_get_set_user(0xff)
#define cpm_set_user(u) cpm_get_set_user(u)
extern uint8_t bios_conin(void);
extern uint8_t bios_const(void);
extern void bios_conout(uint8_t c);
#endif

View file

@ -0,0 +1,15 @@
#
#include "asm.h"
.define _bios_conin
_bios_conin:
lhld 1
lxi d, 6
dad d
push b
call .pchl
pop b
mov e, a
mvi d, 0
ret

View file

@ -0,0 +1,21 @@
#
#include "asm.h"
.define _bios_conout
_bios_conout:
pop h ! pop return address
pop d ! pop parameter into DE
push d
push h
push b
mov c, e
lhld 1
lxi d, 9
dad d
call .pchl
pop b
ret

View file

@ -0,0 +1,16 @@
#
#include "asm.h"
.define _bios_const
_bios_const:
lhld 1
lxi d, 3
dad d
push b
call .pchl
pop b
mov e, a
mvi d, 0
ret

View file

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <cpm.h>
#include "cpmsys.h"

View file

@ -0,0 +1,27 @@
#
#include "asm.h"
! Prints a \0-terminated string.
.define _cpm_printstring0
_cpm_printstring0:
pop h ! pop return address
pop d ! pop parameter (possibly junk)
push d
push h
.1:
ldax d ! fetch byte
ora a
rz ! exit if zero
inx d
push b ! save FP as the BDOS will corrupt it
push d
mov e, a
mvi c, 2 ! conout
call 0x0005
pop d
pop b
jmp .1