Removed ptrsav() and ptrrst() from pointer library

This commit is contained in:
Curtis F Kaylor 2018-01-28 14:29:22 -05:00
parent 7d770f1218
commit 30e15a269e
4 changed files with 19 additions and 66 deletions

View File

@ -6,7 +6,13 @@ These functions are intended to allow sequential reading and writing of
individual bytes to arbitrary locations in memory.
Only one pointer may be active at a time, but it's contents may be saved
and restored.
and restored using the following code:
savelo = ptrlo; savehi = ptrhi; //save current pointer
ptrlo = savelo; ptrhi = savehi; //restore current pointer
where savelo and savehi are an arbitrary pair of variables defined in the
program.
Note: There is no concept of a null pointer in C02. A pointer containing
the value 0 simply points to the first byte of memory.
@ -106,34 +112,13 @@ The following application functions are defined:
Note: Sets variables srclo and srchi.
ptrsav(&r); Pointer Save: Copies the pointer contents into the
first to bytes of array r.
This is roughly equivalent to the C code
r = (int) p;
Note: Sets variables srclo, srchi, and temp0.
Note: This library expects the following to be defined:
ptrrst(&r); Pointer Restore: Copies the first to bytes of array r
into the pointer contents.
This is roughly equivalent to the C code
p = (void*) r;
Note: Sets variables srclo, srchi, ptrlo, and ptrhi.
Note: This library expects the following functions to be defined
setsrc(&s); Set source string pointer and initialize index
along with the zero page variable pairs
the zero page variable pair
strlo, strhi Source String Pointer
ptrlo, ptrhi System Pointer
as well as the transient variable
and the transient variable
temp0 Temporary storage

View File

@ -1,5 +1,5 @@
;C02 library pointer.h02 assembly language subroutines
;Requires External Zero Page Variables PTRLO, PTRHI, SRCLO, SRCHI
;Requires External Zero Page Variables PTRLO, PTRHI
;External Routines MSETSRC
;ptrset(&a) - Set Pointer Address
@ -86,26 +86,3 @@ PTRSUB: STA TEMP0 ;Save Offset
BCS PTRRET ;If Borrow
DEC PTRHI ; Decrement High Byte
RTS
;ptrsav(&a) - Save Pointer Address
;Args: X,Y = Address of Array to Save Pointer in
;Sets: SRCLO, SRCHI = Address of Array
PTRSAV: JSR SETSRC ;Save Address & Initialize Y Index
LDA PTRLO ;Get Pointer Low Byte
STA (SRCLO),Y ;Store In First Byte of Array\
INY ;Increment Index
LDA PTRHI ;Get Pointer High Byte
STA (SRCLO),Y ;Store In Second Byte of Array
RTS
;ptrrst(&a) - Restore Pointer Address
;Args: X,Y = Address of Array to Restore Address
;Sets: SRCLO, SRCHI = Address of Array
; PTRLO, PRTHI = Pointer Value Stores in Array
PTRRST: JSR SETSRC ;Save Address & Initialize Y Index
LDA (SRCLO),Y ;Get First Byte of Array
STA PTRLO ;Store in Pointer Low Byte
INY ;Increment Index
LDA (SRCLO),Y ;Get Second Byte of Array
STA PTRHI ;Store in Pointer High Byte
RTS

View File

@ -37,11 +37,3 @@ void ptrsub();
* 0 = Pointer = Address *
* 1 = Pointer > Address */
void ptrcmp();
/* Save Pointer Value *
* Args: &a - Address to save pointer to */
void ptrsav();
/* Restore Pointer Value *
* Args: &a - Address to restore pointer from */
void ptrrst();

View File

@ -6,7 +6,8 @@
#include <stdio.h02>
#include <pointer.h02>
char psave[2]; //Pointer Storage Variable
char savelo, savehi; //Pointer Storage Variable
char ptemp; //Memory Marker for Compare
main:
//Set Pointer to Cassette Buffer
@ -21,8 +22,8 @@ main:
prbyte(ptrcmp(&temp0)); newlin();
outstr(" TBFFR $");
prbyte(ptrcmp(&tbffr)); newlin();
outstr(" PSAVE $");
prbyte(ptrcmp(&psave)); newlin();
outstr(" PTEMP $");
prbyte(ptrcmp(&ptemp)); newlin();
newlin();
anykey();
@ -55,15 +56,13 @@ main:
anykey();
//Demonstrate Save and Restore
putstr("SAVE POINTER TO PSAVE");
ptrsav(&psave);
outstr(" PSAVE IS NOW ");
prbyte(psave[1]); prbyte(psave[0]); newlin();
putstr("SAVE POINTER");
savelo = ptrlo; savehi = ptrhi;
putstr("CLEAR POINTER");
ptrlo = 0; ptrhi = 0;
prpntr();
putstr("RESTORE FROM PSAVE");
ptrrst(&psave);
ptrlo = savelo; ptrhi = savehi;
prpntr();
goto exit;