1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-25 06:31:25 +00:00

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. individual bytes to arbitrary locations in memory.
Only one pointer may be active at a time, but it's contents may be saved 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 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. 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. 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 Note: This library expects the following to be defined:
r = (int) p;
Note: Sets variables srclo, srchi, and temp0.
ptrrst(&r); Pointer Restore: Copies the first to bytes of array r the zero page variable pair
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
strlo, strhi Source String Pointer ptrlo, ptrhi System Pointer
as well as the transient variable and the transient variable
temp0 Temporary storage temp0 Temporary storage

View File

@ -1,5 +1,5 @@
;C02 library pointer.h02 assembly language subroutines ;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 ;External Routines MSETSRC
;ptrset(&a) - Set Pointer Address ;ptrset(&a) - Set Pointer Address
@ -86,26 +86,3 @@ PTRSUB: STA TEMP0 ;Save Offset
BCS PTRRET ;If Borrow BCS PTRRET ;If Borrow
DEC PTRHI ; Decrement High Byte DEC PTRHI ; Decrement High Byte
RTS 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 * * 0 = Pointer = Address *
* 1 = Pointer > Address */ * 1 = Pointer > Address */
void ptrcmp(); 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 <stdio.h02>
#include <pointer.h02> #include <pointer.h02>
char psave[2]; //Pointer Storage Variable char savelo, savehi; //Pointer Storage Variable
char ptemp; //Memory Marker for Compare
main: main:
//Set Pointer to Cassette Buffer //Set Pointer to Cassette Buffer
@ -21,8 +22,8 @@ main:
prbyte(ptrcmp(&temp0)); newlin(); prbyte(ptrcmp(&temp0)); newlin();
outstr(" TBFFR $"); outstr(" TBFFR $");
prbyte(ptrcmp(&tbffr)); newlin(); prbyte(ptrcmp(&tbffr)); newlin();
outstr(" PSAVE $"); outstr(" PTEMP $");
prbyte(ptrcmp(&psave)); newlin(); prbyte(ptrcmp(&ptemp)); newlin();
newlin(); newlin();
anykey(); anykey();
@ -55,15 +56,13 @@ main:
anykey(); anykey();
//Demonstrate Save and Restore //Demonstrate Save and Restore
putstr("SAVE POINTER TO PSAVE"); putstr("SAVE POINTER");
ptrsav(&psave); savelo = ptrlo; savehi = ptrhi;
outstr(" PSAVE IS NOW ");
prbyte(psave[1]); prbyte(psave[0]); newlin();
putstr("CLEAR POINTER"); putstr("CLEAR POINTER");
ptrlo = 0; ptrhi = 0; ptrlo = 0; ptrhi = 0;
prpntr(); prpntr();
putstr("RESTORE FROM PSAVE"); putstr("RESTORE FROM PSAVE");
ptrrst(&psave); ptrlo = savelo; ptrhi = savehi;
prpntr(); prpntr();
goto exit; goto exit;