1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-28 19:29:39 +00:00
C02/doc/stdiox.txt
2018-07-29 20:40:31 -04:00

143 lines
6.6 KiB
Plaintext

Extended Input/Output Functions for C02 Programs
At the beginning of the program use the directives
#include <stddef.h02>
#include <stdlib.h02>
#include <stdiox.h02>
The following functions are defined:
c = getprc(&s); Writes the string s, waits for a key to be pressed.
then writes blank line
Returns the ASCII value of the key that was
pressed.
Note: Calls the puts function, the newlin
function twice, then the getc function.
c = anykey(); Writes the string "Press any key to continue...",
followed by a blank line, to the screen, then waits
for a key to be pressed.
Returns the ASCII value of the key that was
pressed.
Note: Calls the getprc function, with a hard
coded string.
putspc(b); Writes a space character to the screen.
Note: Used by the putdel and putder functions.
putdec(b); Writes the decimal representation of byte b to the
screen. The output will be between one and three
digits with no leading spaces.
Note: Calls part of the ctoa routine from stdlib
which leaves the binary values of the ones, tens,
and hundreds digits in variables temp0, temp1, and
temp2, respectively.
putdel(b); Writes the decimal representation of byte b to the
screen. The output is left justified by appending it
with 1 space if b is between 10 and 99, or two spaces
if b is less than 10.
Note: Calls putdec and putspc. Leaves the value
of b in varible temp3.
putder(b); Writes the decimal representation of byte b to the
screen. The output is right justified by prepending it
with 1 space if b is between 10 and 99, or two spaces
if b is less than 10.
Note: Calls putdec and putspc. Leaves the value
of b in varible temp3.
puthex(b); Writes the hexadecimal representation of byte b to the
screen. The output is always two hex digits, the first
being a leading 0 if b is less than 16.
Note: Aliased to the prbyte routine.
putwrd(&d); Writes the hexadecimal representation of address &d to
the screen. The output is always four hex digits, with
leading zeros if b is less than $1000.
Note: Calls savrxy, saving the X and Y registers to
temp1 and temp2, respectively, then calls puthex, once
for the most significant byte and again for the least
significant byte.
putdst(); Prints the destination string set by the setdst or
setstr functions.
This can be used to print the results of any function
call that stores it's result in the destination string,
such as strcat, strcpy, and strcut in string,
Note: calls putc and is called by printf when
processing a %S formatting tag.
r = printf(b, &s): Writes the value of byte b to screen, formatting
the output according the contents of string s.
The output consists of the characters in s, but with
any formatting tags replaced with an ASCII
representation of the value of b.
The recognized formatting tags are:
%C - output the ASCII character represented by b
%D - output b as a an unjustified decimal number
%H - output b as a two-digit hexadecimal number
%L - output b as a left justified decimal number
%R - output b as a right justified decimal number
%% - output a single % character
Unlike the printf function in standard C, only
one value argument may be passed and that value is
used for each formatting tag in the format string.
Two additional formatting tag are supported:
%S - output the destination string
%W - output the destination address as a
as a four-digit hexadecimal number
The destination string and/or address is set using
the setdst or strdst function (from the "string"
library) before calling printf. Multiple occurances
of the %S or %w tag will cause the destination string
and/or address to be repeated.
When tag types are mixed, the %S and/or %W tags will
output the destination string and/or address, while
the other tags will output the formatted byte. If
only the %S and/or %W tags are used, then the byte
argument may be excluded from the call.
The letter in the formatting tag may be upper or
lower case with either a 0 or 1 in the high bit.
Unrecognized formatting tags are interpreted as %C.
Note: Calls putdec, putdel, putder, puthex, putwrd,
or putdst depending on which formatting tags are
used. The value of b is left in variable temp3.
Note: This library expects the following functions to be defined:
cubcd(); Convert byte to BCD and unpack into three bytes
prbyte(); Print byte to screen as hexadecimal number
prchr(c); Print ASCII character to screen
savrxy(); Save X and Y registers.
setsrc(&s); Set source string pointer and initialize index
along with the zero page variable pairs:
srclo,srchi: Source string pointer
and the temporary variables
temp0,temp1,temp2,temp3