1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-08 06:29:32 +00:00

Updated documentation files

Added MODIFIERS to c02.txt
Updated quickref.odt and stdiox.txt
Added memio.txt
This commit is contained in:
Curtis F Kaylor 2018-07-18 23:44:42 -04:00
parent 84cf778964
commit 4dbeeb5274
4 changed files with 206 additions and 4 deletions

View File

@ -101,7 +101,7 @@ in order to successfully assemble the compiler generated code. Details
on the structure and implementation of a typical header file can be
found in the file header.txt.
Assembly language files are denoted by the .asm extension. When the
Assembly language files are denoted by the .a02 extension. When the
compiler processes an assembly language file, it simply inserts the contents
of the file into the generated code.
@ -343,8 +343,27 @@ Examples:
Note: Unlike simple and array variable, the members of a struct variable
may not be initialized during declaration.
EXPRESSIONS
MODIFIERS
A modifier is used with a declaration to override the default properties of
an object. Modifiers may currently only be used with simple variable and
array declarations, although this may be expanded in the future.
The zeropage modifier specifies that the variable will be defined in page
zero (addresses 0 through 255). It should be used in conjunction with the
pragma zeropage directive.
The aligned directive specifies that the the variable or array will start on
a page variable. This is used to ensure that accessing an array element will
not cross a page boundary, which requires extra CPU cycles to execute.
Examples:
zeropage char ptr, tmp;
aligned char table[240], fbncci[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34};
EXPRESSIONS
An expression is a series of one or more terms separated by operators.
The first term in an expression may be a function call, subscripted array
@ -500,7 +519,7 @@ arguments may be passed.
When passing the address of a variable, array, struct, or struct member
into a function, the variable specification is prefixed with the
address-of operator &. Wjen passing a string, the string is simply
address-of operator &. When passing a string, the string is simply
specified as the argument with.
Examples:
@ -684,7 +703,7 @@ of code to be executed if the evaluation was false.
Examples:
if (c = 27) goto end;
if (n) q = (n/d) else puts("Division by 0!");
if (n) q = div(n,d) else puts("Division by 0!");
if (r[j]<r[i]) {t=r[i],r[i]=r[j],r[j]=t)}
Note: In order to optimize the compiled code, the if and else statements

104
doc/memio.txt Normal file
View File

@ -0,0 +1,104 @@
Memory File I/O Functions
This library contains functions that mimic file input/ouput operations,
but read and write directly to RAM. It is intended to allow for the
design of programs using these functions even on systems that do not
include any sort of filesystem support, but do allow blocks of memory
to be loaded from and saved to external storage. For this reason, each
function has the same signature it's equivalent in the file library.
At the beginning of the program use the directives
#include <memio.h02>
The following functions are defined:
m = mopen(z, &a); Open memory file, using zero-page bytes z and z+1
as a pointer and a as the starting address of the
file. The starting address must be at least $0100.
Returns the the z as the "file pointer", or 0 if an
invalid address is specified.
r = mclose(m); Close memory file pointed to by m, by writing an
EOF and clearing the memory pointer.
Returns 0 if successful or 255 if m contains an
invalid address.
Note: Calls mflush() then sets the bytes at`m and
m+1 to 0.
r = mflush(m); Flush memory file pointed to by m, by writing a
NUL character at the memory pointer to 0.
Returns 0 if successful or 255 if m contains an
invalid address.
Note: The NUL character (ASCII code 0) is use as the
EOF marker because many systems initialize RAM to 0,
it's the easiest character to test for, and it can
never be part of a C style string.
c = mgetc(m); Read character from memory file pointed to by m.
Returns character read from file.
Note: Returns 255 if m contains an invalid address.
Returns a system dependent garbage character if end
of file has been reached or any other I/O error. Use
meof(f) and merror(f) to check for these conditions.
r = mputc(m, c); Write character c to memory file opened to m.
Returns 0 if successful or 255 if m contains an
invalid address.
n, c = mgets(m, &s); Reads a maximum of 128 characters from keyboard until
a newline or EOF character is encountered, storing the
entered characters as null-terminated string s.
Returns number of characters entered ( 255 if m
contains an invalid address) and the final character
of the returned atring.
Note: Any ASCII control character between EOF (code 0)
and Space (code 32) is interpreted as a newline. This
character will be included as the last character of
the string.
n, c = mputs(m, &s): Writes up to 128 characters of null-terminated string
s to the memory file. Does not write a trailing C/R.
Returns number of characters written, or 255 if m
contains an invalid address.
r = mputln(m, &s): Writes up to 128 characters of null-terminated string
s followed by a C/R to the memory file.
Returns 0 if successful or 255 if m contains an
invalid address.
Note: Calls mputs() followed by mputc().
l, h = maddr(m); Returns the address contained in memory pointer m
as two bytes in LSB, MSB format.
This non-standard function is included for debugging
purposes.
Note: This library expects the following functions to be defined:
setdst(&s); Set destination string pointer
setsrc(&s); Set source string pointer and initialize index
along with the zero page variable pairs
dstlo,dsthi: Destination string pointer
srclo,srchi: Source string pointer
and the assembler constant
EOFCHR End of File character code`
RTNCHR Carriage Return character code

Binary file not shown.

79
doc/stdiox.txt Normal file
View File

@ -0,0 +1,79 @@
Extended Input/Output Functions for C02 Programs
At the beginning of the program use the directives
#include <stdlib.h02>
#include <stdiox.h02>
The following functions are defined:
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.
putspc(b); Writes a space character to the screen.
Note: Used by the putdel() and putder() functions.
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.
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(), or prbyte()
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
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