From 541ee6ff673ea4a39e1db46cb48431921d3509df Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Sun, 28 Jan 2018 14:52:58 -0500 Subject: [PATCH] Added Apple-1 C02 test programs --- apple1/a1min.h02 | 25 +++++++++++++++++ apple1/bfrtest.c02 | 20 +++++++++++++ apple1/chrset.c02 | 24 ++++++++++++++++ apple1/chrsetv.c02 | 28 +++++++++++++++++++ apple1/compare1.c02 | 68 +++++++++++++++++++++++++++++++++++++++++++++ apple1/echo.c02 | 16 +++++++++++ apple1/echomin.c02 | 20 +++++++++++++ apple1/ehex.c02 | 18 ++++++++++++ apple1/prdec0.c02 | 20 +++++++++++++ apple1/prdec1.c02 | 20 +++++++++++++ apple1/prdecr.c02 | 20 +++++++++++++ apple1/rndtest.c02 | 25 +++++++++++++++++ apple1/strtest.c02 | 15 ++++++++++ apple1/testio.c02 | 34 +++++++++++++++++++++++ 14 files changed, 353 insertions(+) create mode 100644 apple1/a1min.h02 create mode 100644 apple1/bfrtest.c02 create mode 100644 apple1/chrset.c02 create mode 100644 apple1/chrsetv.c02 create mode 100644 apple1/compare1.c02 create mode 100644 apple1/echo.c02 create mode 100644 apple1/echomin.c02 create mode 100644 apple1/ehex.c02 create mode 100644 apple1/prdec0.c02 create mode 100644 apple1/prdec1.c02 create mode 100644 apple1/prdecr.c02 create mode 100644 apple1/rndtest.c02 create mode 100644 apple1/strtest.c02 create mode 100644 apple1/testio.c02 diff --git a/apple1/a1min.h02 b/apple1/a1min.h02 new file mode 100644 index 0000000..00882de --- /dev/null +++ b/apple1/a1min.h02 @@ -0,0 +1,25 @@ +/* Apple 1 Minimal Header File for Apple 1*/ + +/* Monitor Variables */ +char xaml, xamh; //Examine Index +char stl, sth; //Store Index +char l,h; //Hex Data +char ysave; //Y Register Storage +char mode; //Mode: Store, Examine, Block Examine +char buffer[]; //Input Buffer + +//PIA 6820 Registers +char kbd; //Keyboard Data +char kbdcr; //Keyboard Control Register +char dsp; //Display Data +char dspcr; //Display Control Register + +//Monitor Subroutines +void echo(); //Print Character in Accumulator +void prbyte(); //Print Accumulator as Hexadadecimal number +void prhex(); //Print Low Nybble of Accumulator as Hex Digit + +//System Subroutines +char plkey(); //Poll Keyboard for raw character +char rdkey(); //Wait for raw character from Keyboard + diff --git a/apple1/bfrtest.c02 b/apple1/bfrtest.c02 new file mode 100644 index 0000000..e2df103 --- /dev/null +++ b/apple1/bfrtest.c02 @@ -0,0 +1,20 @@ +/*************************************** + * BUFFER TEST - Test buffer routines * + * from file prdec.asm for Apple 1 * + ***************************************/ + +#include + +#include +#include +#include + +char n; + +main: + n = getbfr(); //Read line into buffer + prdec(n); //Print line length + echo($20); //Print a space + putbfr(); //Print buffer contents + goto main; // and loop + diff --git a/apple1/chrset.c02 b/apple1/chrset.c02 new file mode 100644 index 0000000..c5730a9 --- /dev/null +++ b/apple1/chrset.c02 @@ -0,0 +1,24 @@ +/****************************************** + * CHRSET - Display Apple 1 Character Set * + ******************************************/ + +#include +#include + +byte i; + +main: + i = $20; +loop: + echo(i); + i++; + if (i & $0F == 0) echo($0D); + if (i < $60) goto loop; + echo($0D); + goto exit; + + + + + + diff --git a/apple1/chrsetv.c02 b/apple1/chrsetv.c02 new file mode 100644 index 0000000..b295514 --- /dev/null +++ b/apple1/chrsetv.c02 @@ -0,0 +1,28 @@ +/****************************************** + * CHRSET - Display Apple 1 Character Set * + ******************************************/ + +#include +#include + +byte i, j; + +main: + i = $20; + j = 0; +loop: + echo(i + j); + j = j + 8; + if (j < 64) goto loop; + echo($0D); + j = 0; + i = i + 8; + if (i<96) goto loop; + echo($0D); + goto exit; + + + + + + diff --git a/apple1/compare1.c02 b/apple1/compare1.c02 new file mode 100644 index 0000000..4d6707b --- /dev/null +++ b/apple1/compare1.c02 @@ -0,0 +1,68 @@ +/*********************************** + * COMPARE TEST - Test C02 compare * + * instructions on Apple 1 * + ***********************************/ + +#include +#include +#include +#include + +char passed = " PASSED.\r"; +char failed = " FAILED.\r"; + +main: + prdecr(1); + if (1==1) putstr(&passed); + else putstr(&failed); + + prdecr(2); + if (1==2) putstr(&failed); + else putstr(&passed); + + prdecr(3); + if (1<2) putstr(&passed); + else putstr(&failed); + + prdecr(4); + if (2<1) putstr(&failed); + else putstr(&passed); + + prdecr(5); + if (1<1) putstr(&failed); + else putstr(&passed); + + prdecr(6); + if (1<=2) putstr(&passed); + else putstr(&failed); + + prdecr(7); + if (2<=1) putstr(&failed); + else putstr(&passed); + + prdecr(8); + if (1<=1) putstr(&passed); + else putstr(&failed); + + prdecr(9); + if (2>1) putstr(&passed); + else putstr(&failed); + + prdecr(10); + if (1>2) putstr(&failed); + else putstr(&passed); + + prdecr(11); + if (1>1) putstr(&failed); + else putstr(&passed); + + prdecr(12); + if (1<>2) putstr(&passed); + else putstr(&failed); + + prdecr(13); + if (1<>1) putstr(&failed); + else putstr(&passed); + + goto exit; + diff --git a/apple1/echo.c02 b/apple1/echo.c02 new file mode 100644 index 0000000..b35ae25 --- /dev/null +++ b/apple1/echo.c02 @@ -0,0 +1,16 @@ +/*************************************** + * ECHO - Demo program for the Apple 1 * + * Echos typed keys to display * + * ESC key aborts to monitor * + ***************************************/ + +#include + +char key; //Key value + +main: + key = getkey(); + if (key == 155) goto exit; + echo(key); + goto main; + diff --git a/apple1/echomin.c02 b/apple1/echomin.c02 new file mode 100644 index 0000000..6191b20 --- /dev/null +++ b/apple1/echomin.c02 @@ -0,0 +1,20 @@ +/*************************************** + * ECHO - Demo C02 program for Apple 1 * + * using minimal header file * + * Echos typed keys to display * + * ESC key aborts to monitor * + ***************************************/ + +#include "a1min.h02" + +char key; //Key value + +main: +while() { + key = rdkey(); //Read keyboard + if (key == $9B) //If ESCAPE pressed + break; //exit loop + echo(key); //Display character on screen +} +goto exit; + diff --git a/apple1/ehex.c02 b/apple1/ehex.c02 new file mode 100644 index 0000000..fd1983f --- /dev/null +++ b/apple1/ehex.c02 @@ -0,0 +1,18 @@ +/************************************************** + * ECHO HEX - Demo program for the Apple 1 * + * Displays typed key ASCII values in hexadecimal * + **************************************************/ + +#include +#include + +char key; //Key value + +main: + key = getkey(); + echo(key); + echo(32); + prbyte(key); + echo(32); + goto main; + diff --git a/apple1/prdec0.c02 b/apple1/prdec0.c02 new file mode 100644 index 0000000..0fdca60 --- /dev/null +++ b/apple1/prdec0.c02 @@ -0,0 +1,20 @@ +/*************************************** + * PRDEC0 TEST - Test routine prdec0 * + * from file prdec.asm for Apple 1 * + ***************************************/ + +#include +#include +#include + +byte i; + +main: + +i = 0; +loop: + prdec0(i); + echo(32); + i++; + if (i<>0) goto loop; +goto exit; diff --git a/apple1/prdec1.c02 b/apple1/prdec1.c02 new file mode 100644 index 0000000..93da43f --- /dev/null +++ b/apple1/prdec1.c02 @@ -0,0 +1,20 @@ +/*************************************** + * PRDEC TEST - Test routine prdec * + * from file prdec.asm for Apple 1 * + ***************************************/ + +#include +#include +#include + +byte i; + +main: + +i = 0; +loop: + prdec(i); + echo(32); + i++; + if (i<>0) goto loop; +goto exit; diff --git a/apple1/prdecr.c02 b/apple1/prdecr.c02 new file mode 100644 index 0000000..c885ab2 --- /dev/null +++ b/apple1/prdecr.c02 @@ -0,0 +1,20 @@ +/*************************************** + * PRDEC0 TEST - Test routine prdecr * + * from file prdec.asm for Apple 1 * + ***************************************/ + +#include +#include +#include + +byte i; + +main: + +i = 0; +loop: + prdecr(i); + echo(32); + i++; + if (i<>0) goto loop; +goto exit; diff --git a/apple1/rndtest.c02 b/apple1/rndtest.c02 new file mode 100644 index 0000000..80cf19d --- /dev/null +++ b/apple1/rndtest.c02 @@ -0,0 +1,25 @@ +/************************************************ + * RNDTEST - Test Random Function in apple1.h02 * + ************************************************/ + +#include + +char c, i; //Index +char msg = "Press any key to start"; + +main: + i = 0; +print: + c = msg[i]; + echo(c); + i++; + if (c <> 0) goto print; + echo($0D); + getkey(); + random(count); +loop: + c = random(0); + prbyte(c); + echo(' '); + goto loop; + diff --git a/apple1/strtest.c02 b/apple1/strtest.c02 new file mode 100644 index 0000000..4f1e197 --- /dev/null +++ b/apple1/strtest.c02 @@ -0,0 +1,15 @@ +/********************************************* + * STRTEST - Test Library string.h for Apple * + *********************************************/ + +#include +#include + +char key; //Key value + +main: + key = getkey(); + if (key == 155) goto exit; + echo(key); + goto main; + diff --git a/apple1/testio.c02 b/apple1/testio.c02 new file mode 100644 index 0000000..091f423 --- /dev/null +++ b/apple1/testio.c02 @@ -0,0 +1,34 @@ +/********************************************* + * STRTEST - Test Library stdio.h for Apple * + *********************************************/ + +#include +#include + +char key; //Key read from keyboard +char len; //Length of input output string +char str[128]; //String to read/write + +char anykey = "Press any key to continue"; +char tlines = "Type lines followed by carriage-return"; +char escend = "press Escape key to end"; +char utyped = "You typed: "; + +main: + putstr(&anykey); //Display "Press any key" message + key = getchr(); //Wait for key press + newlin(); //Advance cursor to next line + putstr(&tlines); //Display "Type lines" message + putstr(&utyped); //Display "press Escape" message + +loop: + newlin(); + len = getstr(&str); //Read string from keybaord + if (len == $FF) //If entry was aborted + goto done; + prbyte(len); //Display length of entered string + putstr(&str); //Display entered string + goto loop; + +done: + goto exit;