From 30e15a269edc9407c44806aeda007d815ed0c130 Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Sun, 28 Jan 2018 14:29:22 -0500 Subject: [PATCH] Removed ptrsav() and ptrrst() from pointer library --- doc/pointer.txt | 37 +++++++++++-------------------------- include/pointer.a02 | 25 +------------------------ include/pointer.h02 | 8 -------- vic20/pointers.c02 | 15 +++++++-------- 4 files changed, 19 insertions(+), 66 deletions(-) diff --git a/doc/pointer.txt b/doc/pointer.txt index a2abcd6..9674656 100644 --- a/doc/pointer.txt +++ b/doc/pointer.txt @@ -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 - diff --git a/include/pointer.a02 b/include/pointer.a02 index 88df46f..3499f10 100644 --- a/include/pointer.a02 +++ b/include/pointer.a02 @@ -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 diff --git a/include/pointer.h02 b/include/pointer.h02 index ef34d89..e6ae729 100644 --- a/include/pointer.h02 +++ b/include/pointer.h02 @@ -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(); diff --git a/vic20/pointers.c02 b/vic20/pointers.c02 index 34eace7..97ea425 100644 --- a/vic20/pointers.c02 +++ b/vic20/pointers.c02 @@ -6,7 +6,8 @@ #include #include -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;