mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-30 23:50:04 +00:00
85 lines
1.6 KiB
Plaintext
85 lines
1.6 KiB
Plaintext
/************************************
|
|
* POINTERS - Test pointer.h02 Library *
|
|
************************************/
|
|
|
|
#include "include/vic20.h02"
|
|
#include <stdio.h02>
|
|
#include <pointer.h02>
|
|
|
|
char savelo, savehi; //Pointer Storage Variable
|
|
char ptemp; //Memory Marker for Compare
|
|
|
|
main:
|
|
//Set Pointer to Cassette Buffer
|
|
putstr("SET POINTER TO TBFFR");
|
|
ptrset(&tbffr);
|
|
prpntr();
|
|
newlin();
|
|
|
|
//Demonstrate Compare
|
|
putstr("COMPARE AGAINST");
|
|
outstr(" TEMP0 $");
|
|
prbyte(ptrcmp(&temp0)); newlin();
|
|
outstr(" TBFFR $");
|
|
prbyte(ptrcmp(&tbffr)); newlin();
|
|
outstr(" PTEMP $");
|
|
prbyte(ptrcmp(&ptemp)); newlin();
|
|
newlin();
|
|
|
|
anykey();
|
|
|
|
//Demonstrate Get, Put, Inc, and Dec
|
|
putstr("PUT '*' AT POINTER");
|
|
ptrput('*');
|
|
prpntr();
|
|
putstr("DECREMENT POINTER");
|
|
ptrdec();
|
|
prpntr();
|
|
outstr("GOT FROM POINTER: ");
|
|
putchr(ptrget());
|
|
newlin();
|
|
prpntr();
|
|
putstr("INCREMENT POINTER");
|
|
ptrinc();
|
|
prpntr();
|
|
newlin();
|
|
|
|
//Demonstrate Add and Subtract
|
|
putstr("ADD $FF TO POINTER");
|
|
ptradd($FF);
|
|
prpntr();
|
|
putstr("SUBTRACT $FF");
|
|
ptrsub($FF);
|
|
prpntr();
|
|
newlin();
|
|
|
|
anykey();
|
|
|
|
//Demonstrate Save and Restore
|
|
putstr("SAVE POINTER");
|
|
savelo = ptrlo; savehi = ptrhi;
|
|
putstr("CLEAR POINTER");
|
|
ptrlo = 0; ptrhi = 0;
|
|
prpntr();
|
|
putstr("RESTORE FROM PSAVE");
|
|
ptrlo = savelo; ptrhi = savehi;
|
|
prpntr();
|
|
|
|
goto exit;
|
|
|
|
|
|
//Print Pointer Contents
|
|
void prpntr() {
|
|
outstr(" POINTER IS NOW ");
|
|
prbyte(ptrhi);
|
|
prbyte(ptrlo);
|
|
newlin();
|
|
}
|
|
|
|
//Wait for Keypress
|
|
void anykey() {
|
|
putstr("PRESS ANY KEY...");
|
|
getchr();
|
|
newlin();
|
|
newlin();
|
|
} |