mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-28 10:51:14 +00:00
Updated and tested programs in test/ directory
This commit is contained in:
parent
7c64a32137
commit
9683509797
@ -23,8 +23,8 @@ DSTLO EQU $32 ;Destination String Pointer (string.a02)
|
|||||||
DSTHI EQU $33
|
DSTHI EQU $33
|
||||||
BLKLO EQU $34 ;Block Segment Pointer (block.a02)
|
BLKLO EQU $34 ;Block Segment Pointer (block.a02)
|
||||||
BLKHI EQU $35
|
BLKHI EQU $35
|
||||||
PTRLO EQU $35 ;System Pointer (pointer.a02)
|
STKLO EQU $35 ;System Pointer (pointer.a02)
|
||||||
PTRHI EQU $36
|
STKHI EQU $36
|
||||||
|
|
||||||
RDSEED EQU $3E ;Pseudo-RANDOM Seed
|
RDSEED EQU $3E ;Pseudo-RANDOM Seed
|
||||||
RANDOM EQU $3F ;Pseudo-RANDOM Number Storage
|
RANDOM EQU $3F ;Pseudo-RANDOM Number Storage
|
||||||
@ -34,12 +34,15 @@ TEMP1 EQU $41
|
|||||||
TEMP2 EQU $42
|
TEMP2 EQU $42
|
||||||
TEMP3 EQU $43
|
TEMP3 EQU $43
|
||||||
|
|
||||||
BLKSLO EQU $4A ;Block Start Address
|
BLKLEN EQU $47 ;Block Segment Length
|
||||||
BLKSHI EQU $4B
|
BLKSLO EQU $48 ;Block Start Address
|
||||||
BLKELO EQU $4C ;Block End Address
|
BLKSHI EQU $49
|
||||||
BLKEHI EQU $4D
|
BLKELO EQU $4A ;Block End Address
|
||||||
BLKLEN EQU $4E ;Block Segment Length
|
BLKEHI EQU $4B
|
||||||
|
STKSLO EQU $4C ;Stack Start Address
|
||||||
|
STKSHI EQU $4D
|
||||||
|
STKELO EQU $4E ;Stack End Address
|
||||||
|
STKEHI EQU $4F
|
||||||
|
|
||||||
;PIA 6820 Registers
|
;PIA 6820 Registers
|
||||||
KBD EQU $D010 ;Keyboard Data
|
KBD EQU $D010 ;Keyboard Data
|
||||||
@ -56,8 +59,7 @@ PRHEX EQU $FFE5 ;Subroutine - Print Low Nybble of Accumulator as Hex Digit
|
|||||||
|
|
||||||
START: LDX #$FF ;Reset stack - the monitor doesn't do this
|
START: LDX #$FF ;Reset stack - the monitor doesn't do this
|
||||||
TXS ; (probably because of lack of space)
|
TXS ; (probably because of lack of space)
|
||||||
LDA #$0D ;Move cursor to next line before
|
JSR NEWLIN ;Move cursor to next line before executing program
|
||||||
JSR ECHO ; executing program
|
|
||||||
JMP MAIN ;Execute Program
|
JMP MAIN ;Execute Program
|
||||||
|
|
||||||
|
|
||||||
@ -91,19 +93,3 @@ DELCHR: LDA #DELKEY ;Load Underscore Character
|
|||||||
;Advance Character to Next line
|
;Advance Character to Next line
|
||||||
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
NEWLIN: LDA #$0D ;Load C/R into Accumulator
|
||||||
JMP PRCHR ; and Print it
|
JMP PRCHR ; and Print it
|
||||||
|
|
||||||
;Initialize Destination String Pointer and Index
|
|
||||||
SETDST: STX DSTLO ;Save Destination String Pointer
|
|
||||||
STY DSTHI
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;Initialize Source String Pointer and Index
|
|
||||||
SETSRC: STX SRCLO ;Save Source String Pointer
|
|
||||||
STY SRCHI
|
|
||||||
LDY #$00 ;Initialize Index Into String
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;Retrieve Source String Pointer
|
|
||||||
GETSRC: LDX SRCLO
|
|
||||||
LDY SRCHI
|
|
||||||
RTS
|
|
||||||
|
@ -8,16 +8,24 @@ char ysave; //Y Register Storage
|
|||||||
char mode; //Mode: Store, Examine, Block Examine
|
char mode; //Mode: Store, Examine, Block Examine
|
||||||
char buffer[]; //Input Buffer
|
char buffer[]; //Input Buffer
|
||||||
|
|
||||||
|
//Platform Specific Constants
|
||||||
|
#define DELKEY $5F //Delete/Backspace Key
|
||||||
|
#define ESCKEY $1B //Escape/Stop Key
|
||||||
|
#define RTNKEY $0D //Return/Enter Key
|
||||||
|
|
||||||
/* Standard Library Variables */
|
/* Standard Library Variables */
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
char dstlo,dsthi; //Destination String Pointer for Library Functions
|
||||||
char blklo,blkhi; //Block Segment Pointer
|
char blklo,blkhi; //Block Segment Pointer
|
||||||
char ptrlo,ptrhi; //System Pointer
|
char stklo,skthi; //System Pointer
|
||||||
|
|
||||||
char blkslo, blkshi; //Block Start Address
|
char blkslo, blkshi; //Block Start Address
|
||||||
char blkelo, blkehi; //Block End Address
|
char blkelo, blkehi; //Block End Address
|
||||||
char blklen; //Block Segment Length
|
char blklen; //Block Segment Length
|
||||||
|
|
||||||
|
char stkslo, stkshi; //Stack Start Address
|
||||||
|
char stkelo, stkehi; //Stack End Address
|
||||||
|
|
||||||
char temp0, temp1, temp2, temp3; //Temporary Variables
|
char temp0, temp1, temp2, temp3; //Temporary Variables
|
||||||
|
|
||||||
//PIA 6820 Registers
|
//PIA 6820 Registers
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#define NULKEY $00 //No Key was Pressed
|
#define NULKEY $00 //No Key was Pressed
|
||||||
|
|
||||||
/* Zero Page Variables used as Pointers */
|
/* Zero Page Variables used as Pointers */
|
||||||
char strlo,strhi; //String pointer for String and I/O functions
|
char srclo,srchi; //String pointer for String and I/O functions
|
||||||
char dstlo,dsthi; //Secondary string pointer for String functions
|
char dstlo,dsthi; //Secondary string pointer for String functions
|
||||||
|
|
||||||
char temp0,temp1,temp2,temp3; //Temporary variables
|
char temp0,temp1,temp2,temp3; //Temporary variables
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#define DELKEY $08 //Delete/Backspace Key
|
#define DELKEY $08 //Delete/Backspace Key
|
||||||
#define ESCKEY $1B //Escape/Stop Key
|
#define ESCKEY $1B //Escape/Stop Key
|
||||||
#define RTNKEY $0D //Return/Enter Key
|
#define RTNKEY $0D //Return/Enter Key
|
||||||
#define NULKEY $00 //No Key was Pressed
|
|
||||||
|
|
||||||
//Library Pointer Variables
|
//Library Pointer Variables
|
||||||
char srclo,srchi; //Source String Pointer for Library Functions
|
char srclo,srchi; //Source String Pointer for Library Functions
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*********************************************
|
/************************************************
|
||||||
* stdlib - Template Library Routines for C02 *
|
* template - Template Library Routines for C02 *
|
||||||
*********************************************/
|
************************************************/
|
||||||
|
|
||||||
/* Function Description *
|
/* Function Description *
|
||||||
* Args: a - First Argument *
|
* Args: a - First Argument *
|
||||||
|
@ -38,27 +38,8 @@ USER13 EQU $03FD ;Free Byte for User Programs
|
|||||||
USER14 EQU $03FE ;Free Byte for User Programs
|
USER14 EQU $03FE ;Free Byte for User Programs
|
||||||
USER15 EQU $03FF ;Free Byte for User Programs
|
USER15 EQU $03FF ;Free Byte for User Programs
|
||||||
|
|
||||||
;Cakculated Addresses
|
|
||||||
BASICX EQU BASIC+$0B ;End of Basic Program
|
|
||||||
|
|
||||||
;Machine Language Basic Stub
|
|
||||||
ORG BASIC ;Start
|
|
||||||
DC <BASICX, >BASICX ; Pointer to Next Line
|
|
||||||
DC $00, $00 ; Line Number (0)
|
|
||||||
DC $9E ; SYS
|
|
||||||
DC $20 ; ' '
|
|
||||||
DC SYSADR ; "addr"
|
|
||||||
DC $00 ;End of Line Marker
|
|
||||||
DC $00, $00 ;End of Basic Program
|
|
||||||
|
|
||||||
START: TSX ;Get Stack Pointer
|
START: TSX ;Get Stack Pointer
|
||||||
STX STKSAV ;and Save for Exit
|
STX STKSAV ;and Save for Exit
|
||||||
; LDA #$0E ;Switch to Upper/Lower Case
|
|
||||||
; JSR PRCHR
|
|
||||||
; LDA #$08 ;Disable Commodore+Shift
|
|
||||||
; JSR PRCHR
|
|
||||||
; LDA #$93 ;Clear Screen
|
|
||||||
; JSR PRCHR
|
|
||||||
JMP MAIN ;Execute Program
|
JMP MAIN ;Execute Program
|
||||||
|
|
||||||
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
|
EXIT: LDX STKSAV ;Retrieve Saved Stack Pointer
|
||||||
|
@ -5,8 +5,14 @@ VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
|||||||
CHRROM EQU $8000 ;Character Generator ROM
|
CHRROM EQU $8000 ;Character Generator ROM
|
||||||
VICCLR EQU $9600 ;COLOR RAM (UNEXPANDED)
|
VICCLR EQU $9600 ;COLOR RAM (UNEXPANDED)
|
||||||
|
|
||||||
;BASIC Stub Constants
|
;Machine Language Basic Stub
|
||||||
BASIC EQU $1001 ;Start of BASIC Program
|
ORG $1001 ;Start of Basic Program
|
||||||
SYSADR EQM "4110" ;M/L SYS Address
|
BASIC: DC $0C, $10 ;Pointer to Next Line
|
||||||
|
DC $00, $00 ;Line Number (0)
|
||||||
|
DC $9E ;SYS
|
||||||
|
DC $20 ;' '
|
||||||
|
DC $34,$31,$31,$30 ;"4110"
|
||||||
|
DC $00 ;End of Line Marker
|
||||||
|
DC $00, $00 ;End of Basic Program
|
||||||
|
|
||||||
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
||||||
|
@ -5,8 +5,14 @@ VICSCN EQU $1E00 ;Video Screen Memory Area (Unexpanded)
|
|||||||
CHRROM EQU $8000 ;Character Generator ROM
|
CHRROM EQU $8000 ;Character Generator ROM
|
||||||
VICCLR EQU $9600 ;Color RAM (Unexpanded)
|
VICCLR EQU $9600 ;Color RAM (Unexpanded)
|
||||||
|
|
||||||
;BASIC Stub Constants
|
;Machine Language Basic Stub
|
||||||
BASIC EQU $0401 ;Start of BASIC Program
|
ORG $0401 ;Start of Basic Program
|
||||||
SYSADR EQM "1038" ;M/L SYS Address
|
BASIC: DC $0C, $04 ;Pointer to Next Line
|
||||||
|
DC $00, $00 ;Line Number (0)
|
||||||
|
DC $9E ;SYS
|
||||||
|
DC $20 ;' '
|
||||||
|
DC $31,$30,$33,$38 ;"1038"
|
||||||
|
DC $00 ;End of Line Marker
|
||||||
|
DC $00, $00 ;End of Basic Program
|
||||||
|
|
||||||
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
||||||
|
@ -5,8 +5,14 @@ VICSCN EQU $1000 ;Video Screen Memory Area (Unexpanded)
|
|||||||
CHRROM EQU $8000 ;Character Generator ROM
|
CHRROM EQU $8000 ;Character Generator ROM
|
||||||
VICCLR EQU $9400 ;Color RAM (Unexpanded)
|
VICCLR EQU $9400 ;Color RAM (Unexpanded)
|
||||||
|
|
||||||
;BASIC Stub Constants
|
;Machine Language Basic Stub
|
||||||
BASIC EQU $1201 ;Start of BASIC Program
|
ORG $1201 ;Start of Basic Program
|
||||||
SYSADR EQM "4622" ;M/L SYS Address
|
BASIC: DC $0C, $12 ;Pointer to Next Line
|
||||||
|
DC $00, $00 ;Line Number (0)
|
||||||
|
DC $9E ;SYS
|
||||||
|
DC $20 ;' '
|
||||||
|
DC $34,$36,$32,$32 ;"4622"
|
||||||
|
DC $00 ;End of Line Marker
|
||||||
|
DC $00, $00 ;End of Basic Program
|
||||||
|
|
||||||
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
INCLUDE "../include/vic.a02" ;Include VIC 20 Common Code
|
||||||
|
31
test/_files.txt
Normal file
31
test/_files.txt
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
C02/Test/ - C02 Compiler Test & Demonstration Programs
|
||||||
|
|
||||||
|
Batch Files - Compile and assemble programs for specific systems
|
||||||
|
|
||||||
|
A1.BAT Apple 1 - Creates .ASC file (Woz Monitor Format, 0300R to Run)
|
||||||
|
A2.BAT Apple 2 - Creates .DSK file (Bootable Disk Image)
|
||||||
|
O1.BAT Oric-1 - Creates .TAP file (Oriculator Tape Image)
|
||||||
|
P65.BAT py65mon - Creates .BIN file (Binary file, Load and Run at 0200)
|
||||||
|
V8K.BAT VIC+8K - Creates .PRG file (Program File with BASIC stub)
|
||||||
|
|
||||||
|
Auxillary Files - Used by Batch Files
|
||||||
|
|
||||||
|
s2boot.dsk Apple 2 Bootable Disk Image - Used by A2.BAT
|
||||||
|
xvic.ini VICE Configuration - Used bu V8K.BAT
|
||||||
|
|
||||||
|
C02 Test & Demonstration Files
|
||||||
|
|
||||||
|
echo.c02 Echo typed keys to screen
|
||||||
|
echohex.c02 Display ASCII code of typed keys in Hexadecimal
|
||||||
|
|
||||||
|
conds.c02 Test C02 Conditional Expressions
|
||||||
|
funcs.c02 Test C02 Function Calls and Parameter Passing
|
||||||
|
loops.c02 Test C02 Loop Structures
|
||||||
|
|
||||||
|
forforpf.c02 Demo of printf function from "stringx" module
|
||||||
|
strings.c02 Demo of standard library "string" module
|
||||||
|
|
||||||
|
testhdr.c02 Test system specific Header file functions
|
||||||
|
testsd.c02 Test module "stddef" functions
|
||||||
|
testsl.c02 Test module "stdlib" functions
|
||||||
|
testiox.c02 Test module "stdiox" functions
|
22
test/a1.bat
Normal file
22
test/a1.bat
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
REM Compile and Assemble Program for Apple-1
|
||||||
|
IF EXIST %1.c02 GOTO COMPILE
|
||||||
|
ECHO File %1.c02 not found
|
||||||
|
EXIT /B
|
||||||
|
|
||||||
|
:COMPILE
|
||||||
|
ECHO Compiling File %1.c02
|
||||||
|
..\c02.exe -h apple1 %1 >%1.dbg
|
||||||
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
|
||||||
|
ECHO Assembling File %1.asm
|
||||||
|
dasm %1.asm -f1 -o%1.obj -l%1.lst -s%1.sym
|
||||||
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
|
||||||
|
ECHO Converting Object File
|
||||||
|
python ..\util\bin2asc.py %1
|
||||||
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
DEL %1.obj
|
||||||
|
|
||||||
|
ECHO Copying ASCII File
|
||||||
|
COPY %1.asc C:\Programs\pom1\asc\%1.asc
|
23
test/a2.bat
Normal file
23
test/a2.bat
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
IF EXIST %1.c02 GOTO COMPILE
|
||||||
|
ECHO File %1.c02 not found
|
||||||
|
EXIT /B
|
||||||
|
|
||||||
|
:COMPILE
|
||||||
|
ECHO Compiling File %1.c02
|
||||||
|
..\c02.exe -h apple2 %1 >%1.dbg
|
||||||
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
|
||||||
|
ECHO Assembling File %1.asm
|
||||||
|
dasm %1.asm -f3 -o%1.obj -l%1.lst -s%1.sym
|
||||||
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
|
||||||
|
ECHO Building Disk Image
|
||||||
|
COPY /Y a2boot.dsk %1.dsk
|
||||||
|
ECHO BRUN %1 |python -c "print(input().upper())" |a2tools in t %1.dsk command
|
||||||
|
a2tools in b.0C00 %1.dsk %1 %1.obj
|
||||||
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
DEL %1.obj
|
||||||
|
|
||||||
|
ECHO Starting Emulator
|
||||||
|
START C:\Programs\AppleWin\applewin -d1 %1.dsk
|
67
test/conds.c02
Normal file
67
test/conds.c02
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/****************************************
|
||||||
|
* CONDS - Test Conditional Expressions *
|
||||||
|
****************************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
|
||||||
|
char allok;
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
allok = #TRUE;
|
||||||
|
|
||||||
|
putln("Test Conditionals");
|
||||||
|
|
||||||
|
puts(" 1<>1"); if (1<>1) failed(); else passed();
|
||||||
|
puts(" 1<>2"); if (1<>2) passln(); else failln();
|
||||||
|
puts(" 1==1"); if (1==1) passed(); else failed();
|
||||||
|
puts(" 1==2"); if (1==2) failln(); else passln();
|
||||||
|
puts("1+1=2"); if (1+1 == 2) passed(); else failed();
|
||||||
|
puts(" 2<1"); if (2<1) failln(); else passln();
|
||||||
|
puts(" 1<1"); if (1<1) failed(); else passed();
|
||||||
|
puts(" 1<2"); if (1<2) passln(); else failln();
|
||||||
|
|
||||||
|
puts(" 1<=1"); if (1<=1) passed(); else failed();
|
||||||
|
puts(" 1<=2"); if (1<=2) passln(); else failln();
|
||||||
|
puts(" 2<=1"); if (2<=1) failed(); else passed();
|
||||||
|
puts(" 2>1"); if (2>1) passln(); else failln();
|
||||||
|
puts(" 1>1"); if (1>1) failed(); else passed();
|
||||||
|
puts(" 1>2"); if (1>2) failln(); else passln();
|
||||||
|
puts(" 1>=1"); if (1>=1) passed(); else failed();
|
||||||
|
puts(" 1>=2"); if (1>=2) failln(); else passln();
|
||||||
|
puts(" 2>=1"); if (2>=1) passed(); else failed();
|
||||||
|
puts(" !0:+"); if (!0:+) failln(); else passln();
|
||||||
|
|
||||||
|
puts("$FF:+"); if ($FF:+) failed(); else passed();
|
||||||
|
puts(" $FF"); if ($FF) passln(); else failln();
|
||||||
|
puts("$FF:-"); if ($FF:-) passed(); else failed();
|
||||||
|
puts(" !$FF"); if (!$FF) failln(); else passln();
|
||||||
|
puts("$00:+"); if ($00:+) passed(); else failed();
|
||||||
|
puts(" $00"); if ($00) failln(); else passln();
|
||||||
|
puts("$00:-"); if ($00:-) failed(); else passed();
|
||||||
|
puts(" !$00"); if (!$00) passln(); else failln();
|
||||||
|
|
||||||
|
puts(" 1!0"); if (1|0) passed(); else failed();
|
||||||
|
puts(" !1!0"); if (!1|0) failln(); else passln();
|
||||||
|
puts(" 1&0"); if (1&0) failed(); else passed();
|
||||||
|
puts(" !1&0"); if (!1&0) passln(); else failln();
|
||||||
|
puts(" 1^1"); if (1^1) failed(); else passed();
|
||||||
|
puts(" !1^1"); if (!1^1) passln(); else failln();
|
||||||
|
|
||||||
|
puts(" atoc(\"0\")"); if (atoc("0")) failln(); else passln();
|
||||||
|
puts(" atoc(\"1\")"); if (atoc("1")) passln(); else failln();
|
||||||
|
puts(" atoc(\"127\"):+"); if (atoc("127"):+) passln(); else failln();
|
||||||
|
puts(" atoc(\"128\"):-"); if (atoc("128"):-) passln(); else failln();
|
||||||
|
|
||||||
|
if (allok) putln("All Tests Passed");
|
||||||
|
getc();
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
void passed() {puts(" Pass");}
|
||||||
|
void passln() {passed(); newlin();}
|
||||||
|
void failed() {puts(" Fail"); allok = #FALSE;}
|
||||||
|
void failln() {failed(); newlin();}
|
17
test/echohex.c02
Normal file
17
test/echohex.c02
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/*******************************************************
|
||||||
|
* ECHOHEX - Test/Demo program for C02 Standard Header *
|
||||||
|
* Displays ASCII Code of Typed Keys to Screen *
|
||||||
|
* ESCAPE/STOP key Ends Program *
|
||||||
|
*******************************************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
|
||||||
|
char key; //Key value
|
||||||
|
|
||||||
|
main:
|
||||||
|
while() {
|
||||||
|
key = rdkey();
|
||||||
|
prbyte(key);
|
||||||
|
prchr(' ');
|
||||||
|
if (key==#ESCKEY) goto exit;
|
||||||
|
}
|
20
test/forforpf.c02
Normal file
20
test/forforpf.c02
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/******************************************
|
||||||
|
* FORFORPF - Test Nested FOR with PRINTF *
|
||||||
|
******************************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
#include <stdiox.h02>
|
||||||
|
|
||||||
|
char i,j,result;
|
||||||
|
main:
|
||||||
|
for (i=0;i<5;i++) {
|
||||||
|
for (j=0;j<5;j++) {
|
||||||
|
result=div(mult(mult(i,5)+j,3),5)+32; //(i*5+j)*3/5+32;
|
||||||
|
printf(result,"%d ");
|
||||||
|
}
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
goto exit;
|
71
test/funcs.c02
Normal file
71
test/funcs.c02
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*******************************
|
||||||
|
* FUNCS - Test Function Calls *
|
||||||
|
*******************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
#include <stdiox.h02>
|
||||||
|
|
||||||
|
char i; //index value
|
||||||
|
char n; //result of function call
|
||||||
|
char s[128]; //for Numeric to String conversions
|
||||||
|
char z; //Function Parameters
|
||||||
|
|
||||||
|
const char passed = " Passed.";
|
||||||
|
const char failed = " Failed.";
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
for (i=1;i<5;i++) test(i);
|
||||||
|
putln("Testing complete.");
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
//Test Use of Variable as Parameter
|
||||||
|
void test(z) {
|
||||||
|
select(z) {
|
||||||
|
case 1: test1();
|
||||||
|
case 2: test2();
|
||||||
|
case 3: test3();
|
||||||
|
case 4: test4();
|
||||||
|
default: printf(z, "Bad test value %d\n.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test1() {
|
||||||
|
puts("atoc(\"1\") = ");
|
||||||
|
n = atoc("1");
|
||||||
|
prtnum(n); checkn(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test2() {
|
||||||
|
puts("atoc(\"2\") = ");
|
||||||
|
n = atoc("2");
|
||||||
|
prtnum(n); checkn(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test3() {
|
||||||
|
puts("atoc(\"1\") + 2 = ");
|
||||||
|
n = atoc("1") + 2;
|
||||||
|
prtnum(n); checkn(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4() {
|
||||||
|
puts("abs(atoc(\"255\") + 7 = ");
|
||||||
|
n = abs(atoc("255")) + 7;
|
||||||
|
prtnum(n); checkn(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//uses explicit passing of accumulator
|
||||||
|
void checkn() {if (A == n) pass(); else fail();}
|
||||||
|
|
||||||
|
//uses implicit passing of accumulator
|
||||||
|
void prtnum() {ctoa(&s); puts(&s); putc(':');}
|
||||||
|
|
||||||
|
//one more level of function calls - just because
|
||||||
|
void pass() {putln(&passed);}
|
||||||
|
void fail() {putln(&failed);}
|
@ -2,11 +2,12 @@
|
|||||||
* LOOPS - Test C02 Loop Structures *
|
* LOOPS - Test C02 Loop Structures *
|
||||||
************************************/
|
************************************/
|
||||||
|
|
||||||
#include <py65.h02>
|
//Specify System Header using -H option
|
||||||
|
#include <stddef.h02>
|
||||||
#include <stdio.h02>
|
#include <stdio.h02>
|
||||||
|
|
||||||
char i, b;
|
char i, b;
|
||||||
char failed = " Test Failed!";
|
const char failed = " Test Failed!";
|
||||||
|
|
||||||
main:
|
main:
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ ECHO Assembling File %1.asm
|
|||||||
dasm %1.asm -f1 -o%1.obj -l%1.lst -s%1.sym
|
dasm %1.asm -f1 -o%1.obj -l%1.lst -s%1.sym
|
||||||
IF ERRORLEVEL 1 EXIT /B
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
|
|
||||||
ECHO Building Disk Image
|
ECHO Building Tape Image
|
||||||
python ..\util\orictap.py %1
|
python ..\util\orictap.py %1
|
||||||
IF ERRORLEVEL 1 EXIT /B
|
IF ERRORLEVEL 1 EXIT /B
|
||||||
DEL %1.obj
|
DEL %1.obj
|
||||||
|
15
test/p65.bat
Normal file
15
test/p65.bat
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
IF EXIST %1.c02 GOTO COMPILE
|
||||||
|
ECHO File %1.c02 not found
|
||||||
|
GOTO EOF
|
||||||
|
|
||||||
|
:COMPILE
|
||||||
|
@ECHO Compiling File %1.c02 for py65mon
|
||||||
|
..\c02.exe -h py65 %1 >%1.dbg
|
||||||
|
|
||||||
|
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||||
|
|
||||||
|
@ECHO Assembling File %1.asm
|
||||||
|
C:\Programs\dasm %1.asm -f3 -o%1.bin -l%1.lst -s%1.sym
|
||||||
|
|
||||||
|
:EOF
|
@ -2,40 +2,47 @@
|
|||||||
* STRINGS - Demonstrate string.h02 functions *
|
* STRINGS - Demonstrate string.h02 functions *
|
||||||
**********************************************/
|
**********************************************/
|
||||||
|
|
||||||
#include <py65.h02>
|
//Specify System Header using -H option
|
||||||
#include <stdio.h02>
|
#include <stddef.h02>
|
||||||
#include <stdlib.h02>
|
#include <stdlib.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
#include <string.h02>
|
#include <string.h02>
|
||||||
#include <stringx.h02>
|
#include <stringx.h02>
|
||||||
|
|
||||||
char slen, scmp, spos;
|
char slen, scmp, spos;
|
||||||
char s1 = "First string.";
|
const char s1 = "FIRST STRING.";
|
||||||
char s2 = "Second string.";
|
const char s2 = "SECOND STRING.";
|
||||||
char stest = "123456789012345678901234567890";
|
const char stest = "123456789012345678901234567890";
|
||||||
char stemp[32];
|
char stemp[32];
|
||||||
char sless = "This string is less.";
|
const char smore = "THIS STRING IS MORE.";
|
||||||
char smore = "This string is more.";
|
const char sless = "THIS STRING IS LESS.";
|
||||||
char sprt[4];
|
char sprt[4];
|
||||||
char pass = "Pass";
|
const char pass = "PASS";
|
||||||
char fail = "Fail";
|
const char fail = "FAIL";
|
||||||
|
|
||||||
|
void anykey() {
|
||||||
|
putln("*PRESS A KEY*");
|
||||||
|
if (getkey() == #ESCKEY) goto exit;
|
||||||
|
newlin();
|
||||||
|
}
|
||||||
|
|
||||||
main:
|
main:
|
||||||
//Demo strchr(), strrch()
|
//Demo strchr(), strrch()
|
||||||
putln(&s1); //Print s1 to screen
|
putln(&s1); //Print s1 to screen
|
||||||
puts("Position of first 's' is: ");
|
puts("POSITION OF FIRST 'S' IS: ");
|
||||||
spos = strchr('s', &s1); //Get position of 's'
|
spos = strchr('S', &s1); //Get position of 's'
|
||||||
ctoa(spos, &sprt); //Convert to string
|
ctoa(spos, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
puts("Position of first 'x' is: ");
|
puts("POSITION OF FIRST 'X' IS: ");
|
||||||
spos = strchr('x', &s1); //Get position of 's'
|
spos = strchr('X', &s1); //Get position of 's'
|
||||||
ctoa(spos, &sprt); //Convert to string
|
ctoa(spos, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
puts("Position of last 's' is: ");
|
puts("POSITION OF LAST 'S' IS: ");
|
||||||
spos = strrch('s', &s1); //Get position of 's'
|
spos = strrch('S', &s1); //Get position of 's'
|
||||||
ctoa(spos, &sprt); //Convert to string
|
ctoa(spos, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
puts("Position of last 'x' is: ");
|
puts("POSITION OF LAST 'X' IS: ");
|
||||||
spos = strrch('x', &s1); //Get position of 's'
|
spos = strrch('X', &s1); //Get position of 's'
|
||||||
ctoa(spos, &sprt); //Convert to string
|
ctoa(spos, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
newlin();
|
newlin();
|
||||||
@ -44,61 +51,65 @@ main:
|
|||||||
putln(&stest); //Print stest to screen
|
putln(&stest); //Print stest to screen
|
||||||
slen = strlen(&stest); //Get string length
|
slen = strlen(&stest); //Get string length
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
puts("Length of string is ");
|
puts("LENGTH OF STRING IS ");
|
||||||
putln(&sprt); //Print length to screen
|
putln(&sprt); //Print length to screen
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
//Demo setstr();
|
//Demo setstr();
|
||||||
strdst(&stemp); //Set stemp as destination street
|
strdst(&stemp); //Set stemp as destination street
|
||||||
puts("Address of stemp is $");
|
puts("ADDRESS OF STEMP IS $");
|
||||||
prbyte(dsthi); //Print stored address to string
|
prbyte(dsthi); //Print stored address to string
|
||||||
prbyte(dstlo);
|
prbyte(dstlo);
|
||||||
newlin();
|
newlin();
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
|
anykey();
|
||||||
|
|
||||||
//Demo strcpy()
|
//Demo strcpy()
|
||||||
putln("Copying s1 to stemp: ");
|
putln("COPYING S1 TO STEMP: ");
|
||||||
strdst(&stemp); //Set Destination String
|
strdst(&stemp); //Set Destination String
|
||||||
slen = strcpy(&s1); //Copy s1 into Destination String
|
slen = strcpy(&s1); //Copy s1 into Destination String
|
||||||
puts("String stemp contains: ");
|
puts("STRING STEMP CONTAINS: ");
|
||||||
putln(&stemp); //Print stest to screen
|
putln(&stemp); //Print stest to screen
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
puts("Total characters copied: ");
|
puts("TOTAL CHARACTERS COPIED: ");
|
||||||
putln(&sprt); //Print length to screen
|
putln(&sprt); //Print length to screen
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
//Demo strcat()
|
//Demo strcat()
|
||||||
putln("Concatenating s2 to stemp: ");
|
putln("CONCATENATING S2 TO STEMP: ");
|
||||||
strdst(&stemp); //Set Destination String
|
strdst(&stemp); //Set Destination String
|
||||||
slen = strcat(&s2); //Copy s1 into Destination String
|
slen = strcat(&s2); //Copy s1 into Destination String
|
||||||
puts("String stemp contains: ");
|
putln("STRING STEMP CONTAINS: ");
|
||||||
putln(&stemp); //Print stest to screen
|
puts(" "); putln(&stemp); //Print stest to screen
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
puts("Length of concatenated string is ");
|
puts("LENGTH OF CONCATENATED STRING IS ");
|
||||||
putln(&sprt); //Print length to screen
|
putln(&sprt); //Print length to screen
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
//Demo strcut()
|
//Demo strcut()
|
||||||
putln("Cutting s2 at position 7 to stemp: ");
|
putln("CUTTING S2 AT POSITION 7 TO STEMP: ");
|
||||||
strdst(&stemp); //Set Destination String
|
strdst(&stemp); //Set Destination String
|
||||||
slen = strcut(7, &s2); //Copy s1 into Destination String
|
slen = strcut(7, &s2); //Copy s1 into Destination String
|
||||||
puts("String stemp contains: ");
|
puts("STRING STEMP CONTAINS: ");
|
||||||
putln(&stemp); //Print stest to screen
|
putln(&stemp); //Print stest to screen
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
puts("Length of cut string is ");
|
puts("LENGTH OF CUT STRING IS ");
|
||||||
putln(&sprt); //Print length to screen
|
putln(&sprt); //Print length to screen
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
|
anykey();
|
||||||
|
|
||||||
//Demo strcmp();
|
//Demo strcmp();
|
||||||
puts("Comparing sless to smore: ");
|
puts("COMPARING SLESS TO SMORE: ");
|
||||||
strdst(&sless);
|
strdst(&sless);
|
||||||
scmp = strcmp(&smore);
|
scmp = strcmp(&smore);
|
||||||
prbyte(scmp); newlin();
|
prbyte(scmp); newlin();
|
||||||
puts("Comparing sless to sless: ");
|
puts("COMPARING SLESS TO SLESS: ");
|
||||||
strdst(&sless);
|
strdst(&sless);
|
||||||
scmp = strcmp(&sless);
|
scmp = strcmp(&sless);
|
||||||
prbyte(scmp); newlin();
|
prbyte(scmp); newlin();
|
||||||
puts("Comparing smore to sless: ");
|
puts("COMPARING SMORE TO SLESS: ");
|
||||||
strdst(&smore);
|
strdst(&smore);
|
||||||
scmp = strcmp(&sless);
|
scmp = strcmp(&sless);
|
||||||
prbyte(scmp); newlin();
|
prbyte(scmp); newlin();
|
||||||
@ -106,17 +117,17 @@ main:
|
|||||||
|
|
||||||
//Demo strspn();
|
//Demo strspn();
|
||||||
putln(&stest); //Print test to screen
|
putln(&stest); //Print test to screen
|
||||||
puts("Span matching \"0123\" is: ");
|
puts("SPAN MATCHING \"0123\" IS: ");
|
||||||
strdst(&stest); //Set string to search
|
strdst(&stest); //Set string to search
|
||||||
slen = strspn("0123"); //Get position of "123"
|
slen = strspn("0123"); //Get position of "123"
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
puts("Span matching \"0123456789\" is: ");
|
puts("SPAN MATCHING \"0123456789\" IS: ");
|
||||||
strdst(&stest); //Set string to search
|
strdst(&stest); //Set string to search
|
||||||
slen = strspn("0123456789"); //Get position of "123"
|
slen = strspn("0123456789"); //Get position of "123"
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
puts("Span matching \"789\" is: ");
|
puts("SPAN MATCHING \"789\" IS: ");
|
||||||
strdst(&stest); //Set string to search
|
strdst(&stest); //Set string to search
|
||||||
slen = strspn("789"); //Get position of "123"
|
slen = strspn("789"); //Get position of "123"
|
||||||
ctoa(slen, &sprt); //Convert to string
|
ctoa(slen, &sprt); //Convert to string
|
||||||
@ -125,12 +136,14 @@ main:
|
|||||||
|
|
||||||
//Demo strstr();
|
//Demo strstr();
|
||||||
putln(&stest); //Print test to screen
|
putln(&stest); //Print test to screen
|
||||||
puts("Position of \"234\" is: ");
|
puts("POSITION OF \"234\" IS: ");
|
||||||
strdst(&stest); //Set string to search
|
strdst(&stest); //Set string to search
|
||||||
spos = strstr("234"); //Get position of "123"
|
spos = strstr("234"); //Get position of "123"
|
||||||
ctoa(spos, &sprt); //Convert to string
|
ctoa(spos, &sprt); //Convert to string
|
||||||
putln(&sprt); //Print position to screen
|
putln(&sprt); //Print position to screen
|
||||||
newlin();
|
newlin();
|
||||||
|
|
||||||
|
newlin();
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
21
test/testhdr.c02
Normal file
21
test/testhdr.c02
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/**************************************************
|
||||||
|
* TESTHDR - Test C02 system specific Header file *
|
||||||
|
**************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
//use -h option on command line
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
prchr('P');
|
||||||
|
prchr('R');
|
||||||
|
prchr('C');
|
||||||
|
prchr('H');
|
||||||
|
prchr('R');
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
getkey();
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
|
79
test/testiox.c02
Normal file
79
test/testiox.c02
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/***********************************************
|
||||||
|
* TESTIOX - Test Library stdiox.h for py65mon *
|
||||||
|
***********************************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
#include <stdio.h02>
|
||||||
|
#include <stdiox.h02>
|
||||||
|
|
||||||
|
char i, j;
|
||||||
|
const char s = "STRING";
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
getcpr("PRESS A KEY TO BEGIN");
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
putln("PRTDEC()");
|
||||||
|
do {
|
||||||
|
putdec(i);
|
||||||
|
putc(':');
|
||||||
|
i++;
|
||||||
|
if (!i&7) newlin();
|
||||||
|
if (!i&127) anykey();
|
||||||
|
} while (i);
|
||||||
|
|
||||||
|
putln("PRTDEL()");
|
||||||
|
do {
|
||||||
|
putdel(i);
|
||||||
|
putc(':');
|
||||||
|
i++;
|
||||||
|
if (!i&7) newlin();
|
||||||
|
if (!i&127) anykey();
|
||||||
|
} while (i);
|
||||||
|
|
||||||
|
putln("PRTDER()");
|
||||||
|
do {
|
||||||
|
putder(i);
|
||||||
|
putc(':');
|
||||||
|
i++;
|
||||||
|
if (!i&7) newlin();
|
||||||
|
if (!i&127) anykey();
|
||||||
|
} while (i);
|
||||||
|
|
||||||
|
putln("PRTHEX()");
|
||||||
|
do {
|
||||||
|
puthex(i);
|
||||||
|
putc(':');
|
||||||
|
i++;
|
||||||
|
if (!i&7) newlin();
|
||||||
|
if (!i&127) anykey();
|
||||||
|
} while (i);
|
||||||
|
|
||||||
|
putln("PRTWRD()");
|
||||||
|
do {
|
||||||
|
j = i ^ $FF;
|
||||||
|
putwrd(*,i,j);
|
||||||
|
putc(':');
|
||||||
|
i++;
|
||||||
|
if (!i&3) newlin();
|
||||||
|
if (!i&63) anykey();
|
||||||
|
} while (i);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!i&15) putln("%C %H .%R %L. %D%%");
|
||||||
|
if (i<32) printf(i, " %h %r %l %d%%%n");
|
||||||
|
else printf(i," %c %h %r %l %d%%%n");
|
||||||
|
i++; if (!i&15) anykey();
|
||||||
|
} while (i<128);
|
||||||
|
|
||||||
|
putln("%W.. '%S'");
|
||||||
|
setdst(&s);
|
||||||
|
printf("%w '%s'%n");
|
||||||
|
|
||||||
|
done:
|
||||||
|
goto exit;
|
||||||
|
|
82
test/testsd.c02
Normal file
82
test/testsd.c02
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/************************************************
|
||||||
|
* TESTSD - Test Library stddef.h02 for py65mon *
|
||||||
|
************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
//use -h option on command line
|
||||||
|
#include <stddef.h02>
|
||||||
|
|
||||||
|
const char txtstr = {
|
||||||
|
"#TRUE=",", #FALSE=",
|
||||||
|
"SAVREG($A,$B,$C)", " TEMP0,1,2=",
|
||||||
|
"RESREG()", " A,X,Y=",
|
||||||
|
"SETSRC(&$1234)"," SRCLO,HI=", " GETSRC()=",
|
||||||
|
"SETDST(&$5678)"," DSTLO,HI=", " GETDST()="
|
||||||
|
};
|
||||||
|
char txtidx;
|
||||||
|
|
||||||
|
char aa,xx,yy;
|
||||||
|
|
||||||
|
main:
|
||||||
|
txtidx = 0;
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
prttxt(); prbyte(#TRUE);
|
||||||
|
prttxt(); prbyte(#FALSE);
|
||||||
|
newlin(); newlin();
|
||||||
|
|
||||||
|
temp0=0; temp1=0; temp3 = 0;
|
||||||
|
prtlin(); savreg($A,$B,$C);
|
||||||
|
prttxt(); prbyte(temp0);
|
||||||
|
prtcma(); prbyte(temp1);
|
||||||
|
prtcma(); prbyte(temp2);
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
setreg(0,0,0);
|
||||||
|
prtlin(); aa,yy,xx = resreg();
|
||||||
|
prttxt(); prbyte(aa);
|
||||||
|
prtcma(); prbyte(yy);
|
||||||
|
prtcma(); prbyte(xx);
|
||||||
|
newlin(); newlin();
|
||||||
|
|
||||||
|
|
||||||
|
srclo = 0; srchi = 0;
|
||||||
|
prtlin(); setsrc(&$1234);
|
||||||
|
prttxt(); prbyte(srclo);
|
||||||
|
prtcma(); prbyte(srchi);
|
||||||
|
newlin();
|
||||||
|
prttxt(); setreg(0,0,0);
|
||||||
|
getsrc(); prtwrd();
|
||||||
|
newlin(); newlin();
|
||||||
|
|
||||||
|
dstlo = 0; dsthi = 0;
|
||||||
|
prtlin(); setdst(&$5678);
|
||||||
|
prttxt(); prbyte(dstlo);
|
||||||
|
prtcma(); prbyte(dsthi);
|
||||||
|
newlin();
|
||||||
|
prttxt(); setreg(0,0,0);
|
||||||
|
getdst(); prtwrd();
|
||||||
|
newlin(); newlin();
|
||||||
|
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
void setreg(aa,yy,xx) {}
|
||||||
|
|
||||||
|
void prtwrd(aa,yy,xx) {
|
||||||
|
prbyte(yy);
|
||||||
|
prbyte(xx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void prtcma() {prchr(',');}
|
||||||
|
|
||||||
|
void prtlin() {prttxt(); newlin();}
|
||||||
|
|
||||||
|
void prttxt() {
|
||||||
|
while (txtstr[txtidx]) {
|
||||||
|
//prbyte(txtidx);prchr(' ');
|
||||||
|
prchr(txtstr[txtidx]);
|
||||||
|
txtidx++;
|
||||||
|
}
|
||||||
|
txtidx++;
|
||||||
|
}
|
220
test/testsl.c02
Normal file
220
test/testsl.c02
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
/************************************************
|
||||||
|
* TESTSL - Test Library stdlib.h02 for py65mon *
|
||||||
|
************************************************/
|
||||||
|
|
||||||
|
//Specify System Header using -H option
|
||||||
|
#include <stddef.h02>
|
||||||
|
#include <stdlib.h02>
|
||||||
|
|
||||||
|
main:
|
||||||
|
|
||||||
|
tstabs: //Test abs()
|
||||||
|
char onum, anum, cnum;
|
||||||
|
|
||||||
|
prchr('A');
|
||||||
|
prchr('B');
|
||||||
|
prchr('S');
|
||||||
|
prchr(' ');
|
||||||
|
|
||||||
|
//test abs() positive numbers
|
||||||
|
onum = 0;
|
||||||
|
aploop:
|
||||||
|
anum = abs(onum);
|
||||||
|
if (onum <> anum) goto abserr;
|
||||||
|
onum++;
|
||||||
|
if (onum < $80) goto aploop;
|
||||||
|
|
||||||
|
//test abs() negative numbers
|
||||||
|
anloop:
|
||||||
|
anum = abs(onum);
|
||||||
|
cnum = -onum;
|
||||||
|
if (anum <> cnum) goto abserr;
|
||||||
|
onum++;
|
||||||
|
if (onum > $00) goto anloop;
|
||||||
|
prchr('O');
|
||||||
|
prchr('K');
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
tstmlt: //Test mult()
|
||||||
|
char mltplr, mltpnd, acmlsb, acmmsb, acmlst;
|
||||||
|
char prodct, ovrflw;
|
||||||
|
|
||||||
|
mltplr = 1;
|
||||||
|
mrloop:
|
||||||
|
prbyte(mltplr);
|
||||||
|
mltpnd = 1; acmlst = 0;
|
||||||
|
acmlsb = 0; acmmsb = 0;
|
||||||
|
mdloop:
|
||||||
|
acmlsb = acmlsb + mltplr;
|
||||||
|
if (acmlsb<acmlst) acmmsb++;
|
||||||
|
acmlst = acmlsb;
|
||||||
|
prodct,ovrflw = mult(mltplr,mltpnd);
|
||||||
|
if (prodct <> acmlsb) goto merror;
|
||||||
|
//if (ovrflw <> acmmsb) goto merror;
|
||||||
|
mltpnd++;
|
||||||
|
if (mltpnd > 0) goto mdloop;
|
||||||
|
mltplr++;
|
||||||
|
if (mltplr > 0) goto mrloop;
|
||||||
|
newlin();
|
||||||
|
prchr('M');
|
||||||
|
prchr('U');
|
||||||
|
prchr('L');
|
||||||
|
prchr('T');
|
||||||
|
prchr(' ');
|
||||||
|
prchr('O');
|
||||||
|
prchr('K');
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
tstdiv: //Test div()
|
||||||
|
char maxmpd, divdnd, divisr, quotnt;
|
||||||
|
|
||||||
|
mltplr = 255;
|
||||||
|
maxmpd = 1;
|
||||||
|
drloop:
|
||||||
|
prbyte(mltplr);
|
||||||
|
mltpnd = 1;
|
||||||
|
acmlsb = 0;
|
||||||
|
ddloop:
|
||||||
|
prbyte(mltpnd);
|
||||||
|
acmlsb = acmlsb + mltplr;
|
||||||
|
prodct = mult(mltplr, mltpnd);
|
||||||
|
quotnt = div(prodct, mltpnd);
|
||||||
|
if (quotnt <> mltplr) goto derror;
|
||||||
|
mltpnd++;
|
||||||
|
if (mltpnd < maxmpd) goto ddloop;
|
||||||
|
newlin();
|
||||||
|
mltplr>>;
|
||||||
|
maxmpd<<;
|
||||||
|
if (mltplr <> 0) goto drloop;
|
||||||
|
newlin();
|
||||||
|
prchr('D');
|
||||||
|
prchr('I');
|
||||||
|
prchr('V');
|
||||||
|
prchr(' ');
|
||||||
|
prchr('O');
|
||||||
|
prchr('K');
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
|
||||||
|
tstrnd: //Test rand() and rands()
|
||||||
|
char countr, rndnum, rndtbl[255];
|
||||||
|
|
||||||
|
rands(1); //Seed Random Number Generator;
|
||||||
|
|
||||||
|
countr = 0;
|
||||||
|
|
||||||
|
riloop:
|
||||||
|
rndtbl[countr] = 0;
|
||||||
|
countr++;
|
||||||
|
if (countr <> 0) goto riloop;
|
||||||
|
|
||||||
|
rnloop:
|
||||||
|
rndnum = rand();
|
||||||
|
if (rndtbl[rndnum] > 0) goto rnderr;
|
||||||
|
rndtbl[rndnum] = $FF;
|
||||||
|
prbyte(rndnum);
|
||||||
|
prchr(' ');
|
||||||
|
countr++;
|
||||||
|
if (countr < 255) goto rnloop;
|
||||||
|
newlin();
|
||||||
|
prchr('R');
|
||||||
|
prchr('A');
|
||||||
|
prchr('N');
|
||||||
|
prchr('D');
|
||||||
|
prchr(' ');
|
||||||
|
prchr('O');
|
||||||
|
prchr('K');
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
tstc2a: //Test ctoa();
|
||||||
|
char srcchr, dstchr, tststr[4];
|
||||||
|
|
||||||
|
srcchr = 0;
|
||||||
|
caloop:
|
||||||
|
prbyte(srcchr);
|
||||||
|
prchr(' ');
|
||||||
|
ctoa(srcchr, &tststr);
|
||||||
|
dstchr = atoc(&tststr);
|
||||||
|
if (srcchr <> dstchr) goto c2aerr;
|
||||||
|
srcchr++;
|
||||||
|
if (srcchr <> 0) goto caloop;
|
||||||
|
newlin();
|
||||||
|
prchr('C');
|
||||||
|
prchr('T');
|
||||||
|
prchr('O');
|
||||||
|
prchr('A');
|
||||||
|
prchr(' ');
|
||||||
|
prchr('O');
|
||||||
|
prchr('K');
|
||||||
|
newlin();
|
||||||
|
|
||||||
|
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
abserr:
|
||||||
|
prchr('A');
|
||||||
|
prchr('B');
|
||||||
|
prchr('S');
|
||||||
|
prchr('(');
|
||||||
|
prbyte(onum);
|
||||||
|
prchr(')');
|
||||||
|
prchr('=');
|
||||||
|
prbyte(anum);
|
||||||
|
prchr(',');
|
||||||
|
prbyte(cnum);
|
||||||
|
newlin();
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
merror:
|
||||||
|
newlin();
|
||||||
|
prbyte(mltplr);
|
||||||
|
prchr('*');
|
||||||
|
prbyte(mltpnd);
|
||||||
|
prchr('=');
|
||||||
|
//prbyte(ovrflw);
|
||||||
|
prbyte(prodct);
|
||||||
|
prchr(',');
|
||||||
|
//prbyte(acmmsb);
|
||||||
|
prbyte(acmlsb);
|
||||||
|
newlin();
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
derror:
|
||||||
|
newlin();
|
||||||
|
prbyte(divdnd);
|
||||||
|
prchr('/');
|
||||||
|
prbyte(divisr);
|
||||||
|
prchr('=');
|
||||||
|
prbyte(quotnt);
|
||||||
|
prchr(',');
|
||||||
|
prbyte(mltplr);
|
||||||
|
newlin();
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
rnderr:
|
||||||
|
prchr('R');
|
||||||
|
prchr('A');
|
||||||
|
prchr('N');
|
||||||
|
prchr('D');
|
||||||
|
prchr('(');
|
||||||
|
prchr(')');
|
||||||
|
prchr('=');
|
||||||
|
prbyte(rndnum);
|
||||||
|
prchr(',');
|
||||||
|
prbyte(countr);
|
||||||
|
newlin();
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
c2aerr:
|
||||||
|
prchr('C');
|
||||||
|
prchr('T');
|
||||||
|
prchr('O');
|
||||||
|
prchr('A');
|
||||||
|
prchr('(');
|
||||||
|
prbyte(srcchr);
|
||||||
|
prchr(')');
|
||||||
|
prchr('=');
|
||||||
|
prbyte(dstchr);
|
||||||
|
newlin();
|
||||||
|
goto exit;
|
||||||
|
|
18
test/v8k.bat
Normal file
18
test/v8k.bat
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
IF EXIST %1.c02 GOTO COMPILE
|
||||||
|
ECHO File %1.c02 not found
|
||||||
|
GOTO EOF
|
||||||
|
|
||||||
|
:COMPILE
|
||||||
|
ECHO Compiling File %1.c02 for VIC 20 +8k
|
||||||
|
..\c02.exe -H vic8k %1 >%1.dbg
|
||||||
|
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||||
|
ECHO Assembling File %1.asm
|
||||||
|
C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym
|
||||||
|
|
||||||
|
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||||
|
|
||||||
|
ECHO Starting Emulator
|
||||||
|
@start C:\Programs\WinVICE\xvic.exe -config xvic.ini %1.prg
|
||||||
|
|
||||||
|
:EOF
|
22
test/xvic.ini
Normal file
22
test/xvic.ini
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[VIC20]
|
||||||
|
Window0Xpos=523
|
||||||
|
Window0Ypos=58
|
||||||
|
Window0Width=618
|
||||||
|
Window0Height=569
|
||||||
|
FullscreenWidth=640
|
||||||
|
FullscreenHeight=480
|
||||||
|
ConfirmOnExit=0
|
||||||
|
SoundDeviceName="dx"
|
||||||
|
SoundBufferSize=100
|
||||||
|
VirtualDevices=1
|
||||||
|
MachineVideoStandard=2
|
||||||
|
RAMBlock1=1
|
||||||
|
VICVideoCache=1
|
||||||
|
VICFilter=0
|
||||||
|
SidEngine=1
|
||||||
|
SidModel=0
|
||||||
|
DriveTrueEmulation=0
|
||||||
|
ETHERNET_DISABLED=1
|
||||||
|
ETHERNETCARTBase=38912
|
||||||
|
Acia1Base=38912
|
||||||
|
|
53
util/bin2asc.py
Normal file
53
util/bin2asc.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#Binary to ASCII
|
||||||
|
#Converts DASM -F1 file to Apple 1 Monitor format
|
||||||
|
|
||||||
|
#DASM -F1 File two byte load address in LSB, MSB order
|
||||||
|
#followed by binary object coda
|
||||||
|
|
||||||
|
#Apple 1 Monitor Format
|
||||||
|
#ADDR: BYTE BYTE BYTE...
|
||||||
|
#0300: 00 01 02 03 04 05 06 07
|
||||||
|
#0308: 08 09 0A 0B 0C 0D 0E 0F
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def getArgs():
|
||||||
|
argCount = len(sys.argv)
|
||||||
|
if argCount != 2:
|
||||||
|
print("Usage:", sys.argv[0], "objfile")
|
||||||
|
exit(2)
|
||||||
|
return sys.argv[1]
|
||||||
|
|
||||||
|
def splitFileSpec(filePath):
|
||||||
|
fileDir, fileSpec = os.path.split(filePath)
|
||||||
|
fileName, fileExt = os.path.splitext(fileSpec)
|
||||||
|
if fileExt == '': fileExt = '.obj'
|
||||||
|
return fileDir, fileName, fileExt
|
||||||
|
|
||||||
|
def readPrgFile(fileSpec):
|
||||||
|
with open(fileSpec, "rb") as prgFile:
|
||||||
|
prgAddr = prgFile.read(2)
|
||||||
|
prgData = prgFile.read()
|
||||||
|
address = prgAddr[0] + prgAddr[1] * 256
|
||||||
|
return address, prgData
|
||||||
|
|
||||||
|
def writeAscFile(dir, name, addr, data):
|
||||||
|
ascName = os.path.join(dir, name + ".asc")
|
||||||
|
line = "";
|
||||||
|
with open(ascName, "w") as ascFile:
|
||||||
|
for i in range(len(data)):
|
||||||
|
if i & 7 == 0:
|
||||||
|
if len(line): ascFile.write(line + '\n')
|
||||||
|
line = "{:04X}:".format(addr + i)
|
||||||
|
line = line + " {:02X}".format(data[i])
|
||||||
|
ascFile.write(line + '\n')
|
||||||
|
return ascName
|
||||||
|
|
||||||
|
objFile = getArgs()
|
||||||
|
fileDir, fileName, fileExt = splitFileSpec(objFile)
|
||||||
|
inName = os.path.join(fileDir, fileName + fileExt)
|
||||||
|
print("Reading file", inName)
|
||||||
|
inAddr, inData = readPrgFile(inName)
|
||||||
|
outName = writeAscFile(fileDir, fileName, inAddr, inData)
|
||||||
|
print ("Wrote file", outName)
|
Loading…
Reference in New Issue
Block a user