Merge pull request #204 from davidgiven/dtrg-cpm

More CP/M utilities
This commit is contained in:
David Given 2019-06-24 23:54:36 +02:00 committed by GitHub
commit c2604dbb04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 102 additions and 1 deletions

View file

@ -0,0 +1,13 @@
#include <stdio.h>
void itoa(long value, char* buffer, int radix)
{
if (value < 0)
{
*buffer++ = '-';
value = -value;
}
buffer = _i_compute(value, 10, buffer, 0);
*buffer++ = '\0';
}

View file

@ -75,6 +75,7 @@ extern void perror(const char *_s);
/* Internal function used in several places which is approximately itoa(). */
extern char *_i_compute(unsigned long val, int base, char *s, int nrdigits);
extern void itoa(long val, char* buffer, int radix);
#if ACKCONF_WANT_EMULATED_FILE
#include <ack/emufile.h>

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