From 1797d376dbf4f43ea22ab2f14f24acab58b95e13 Mon Sep 17 00:00:00 2001 From: Curtis F Kaylor Date: Thu, 15 Oct 2020 20:19:20 -0400 Subject: [PATCH] Moved block test program from py65/ to test/ --- include/block.a02 | 62 +++++++++++++++------------- py65/testblk.c02 => test/blktest.c02 | 35 ++++++++-------- 2 files changed, 51 insertions(+), 46 deletions(-) rename py65/testblk.c02 => test/blktest.c02 (86%) diff --git a/include/block.a02 b/include/block.a02 index 60eaa4c..144a32a 100644 --- a/include/block.a02 +++ b/include/block.a02 @@ -2,12 +2,14 @@ ;C02 library block.h02 assembly language subroutines ;Requires External Zero Page Variables -;BLKLO, BLKHI, DSTLO, DSTHI, SRCLO, SRCHI +;BLKLO, BLKHI, DSTPTR, SRCPTR ;External Variables ;BLKSLO, BLKSHI, BLKELO, BLKEHI, BLKLEN, TEMP0, TEMP1, TEMP2 ;External Routines ;MEMCMP, MEMCPY, MEMSRC, RESDST, SAVDST, SETDST, SETSRC, SETSRD + SUBROUTINE BLOCK + ;blkbgn(&b) - Set Block Start Address ;Args: X,Y = Address ;Sets: BLKSLO, BLKSHI = Block Start Address @@ -80,8 +82,8 @@ BLKSEX: JMP BLKRST ;Reset Block Pointer and Return ;Args: n = Number of Bytes to Append ; m = Array of Bytes to Append ;Uses: BLKELO, BLKEHI - Block End Address -;Sets: DSTLO, DSTHI = Pointer to Bytes in Block -; SRCHI, SRCLO = Pointer to m +;Sets: DSTPTR = Pointer to Bytes in Block +; SRCPTR = Pointer to m ; TEMP0 = Number of Bytes to Append ;Updates: BLKLO, BLKHI = Block Pointer ;Returns: A=$FF - Append Successful @@ -94,8 +96,8 @@ BLKPUT: JSR MEMSRC ;Set Source Address & Number of Bytes ;Args: A = Number of Bytes to Read ; Y,X = Address of Array ;Uses: BLKELO, BLKEHI = Block End Address -;Sets: DSTLO, DSTHI = Address of Array -; SRCHI, SRCLO = Current Pointer in Block +;Sets: DSTPTR = Address of Array +; SRCPTR = Current Pointer in Block ; TEMP0 = Number of Bytes to Append ;Updates: BLKLO, BLKHI = Next Segment in Block ;Returns: A=$FF - Append Successful @@ -113,14 +115,14 @@ BLKCPY: LDY #0 ;Copy Source To Destination ;blkmem(n, &m) - Search for n Bytes of m in Block ;Args: n = Number of Bytes to Compare ; m = Array of Bytes to Search For -;Sets: DSTLO, DSTHI = Pointer to Segment in Block -; SRCHI, SRCLO = Pointer to m +;Sets: DSTPTR = Pointer to Segment in Block +; SRCPTR = Pointer to m ; TEMP0 = Number of Bytes to Compare ;Returns: A=$FF - Bytes found ; A=$00 - Bytes not found BLKMEM: JSR MEMSRC ;Initialize Source, Index, and Count JSR BLKDSS ;Set Destination Pointer To Block Start - LDX #DSTLO ;Set BLKNXX Pointer to SRCLO,SRCHI + LDX #DSTPTR ;Set BLKNXX Pointer to DSTPTR BLKMEL: LDY #0 ;Initialize Index JSR MEMCML ;Compare Source to Destination BEQ BLKTRU ;If Equal, Exit TRUE @@ -142,17 +144,17 @@ BLKRTS: RTS ;BLKNXD() - Move Destination Pointer to Next Segment ;Uses: BLKLEN - Block Segment Length -;Updates: DSTLO, DSTHI = Block Pointer +;Updates: DSTPTR, DSTPTR+1 = Block Pointer ;Affects: C,N,Z ;Returns: A=$FF - Destination Pointer Moved ; A=$00 - Error: Pointer Overflow or Length 0 -BLKNXD: LDX #DSTLO ;Set X to Destination Pointer +BLKNXD: LDX #DSTPTR ;Set X to Destination Pointer JMP BLKNXX ;and Move to Next Segment ;blknxx() - Move Pointer to Next Segment ;Args: X = Zero Page Address of Pointer ;Uses: BLKLEN - Block Segment Length -;Updates: DSTLO, DSTHI = Block Pointer +;Updates: DSTPTR, DSTPTR+1 = Block Pointer ;Affects: C,N,Z ;Returns: A=$FF - Destination Pointer Moved ; A=$00 - Error: Pointer Overflow or Length 0 @@ -218,8 +220,8 @@ BLKPRL: CMP BLKELO ; >= Block End LSB ; BLKSLO, BLKSHI = Block Start Address ; BLKELO, BLKEHI = Block End Address ; BLKLEN = Block Segment Size -; DSTLO, DSTHI = Pointer to Segment in Block -; SRCHI, SRCLO = Pointer to Segment in Block +; DSTPTR = Pointer to Segment in Block +; SRCPTR = Pointer to Segment in Block ;Affects: A,Y,C,N,Z BLKSRT: LDA BLKLEN ;Get Segment Length BEQ BLKRTS ;If 0 Return @@ -233,16 +235,16 @@ BLKSRP: LDY #0 ;If First Byte of BLKSRD: JSR BLKNXD ;Move Destination Pointer BCS BLKSRE ;If Not Past Block End LDY #0 ; - LDA (DSTLO),Y ;and Destination String Populated + LDA (DSTPTR),Y ;and Destination String Populated BEQ BLKSRE ; JSR STRCML ; Compare Destination String with Source String BPL BLKSRD ; If Destination < Source JSR SETSRD ; Set Source Pointer to Destination Pointer JMP BLKSRD ; Check Next Destination Segment -BLKSRE: LDA SRCHI ;If Source Pointer +BLKSRE: LDA SRCPTR+1 ;If Source Pointer CMP BLKHI ; <> Block Pointer BNE BLKSRS - LDA SRCLO + LDA SRCPTR CMP BLKLO BEQ BLKSRN BLKSRS: JSR BLKSWL ; Swap Source and Pointer @@ -253,8 +255,8 @@ BLKSRN: JSR BLKNXT ;Move Block Pointer ;blkstr(&s) - Search for String s in Block and ; Copy Segment to Destination Array if Found ;Args: Y,X = Address of Search String -;Uses: DSTLO.DSTHI = Address of Destination Array -;Sets: SRCLO,SRCHI = Pointer to Segment in Block (if found) +;Uses: DSTPTR = Address of Destination Array +;Sets: SRCPTR = Pointer to Segment in Block (if found) ; TEMP0 = Index within segment ; TEMP1,TEMP2 = Destination String Pointer ;Affects: Y,C @@ -269,7 +271,7 @@ BLKSTR: JSR SETSRC ;Set Source Pointer to Search String LDX BLKSLO ;Set Source Pointer To Block Start LDY BLKSHI JSR SETSRC - LDX #SRCLO ;Set BLKNXX Pointer to SRCLO,SRCHI + LDX #SRCPTR ;Set BLKNXX Pointer to SRCPTR BLKSTL: LDY #0 ;Initialize Index JSR STRCML ;Compare Source to Destination BEQ BLKSTS ;If Not Equal @@ -286,7 +288,7 @@ BLKSTS: JSR RESDST ; Restore Destination Pointer ; m = Array to swap bytes from ;Sets: TEMP0 = Number of Bytes to Swap ;Uses: BLKLO, BLKHI = Block Pointer -; DSTLO, DSTHI = Pointer to Temporary Storage Array +; DSTPTR, DSTPTR+1 = Pointer to Temporary Storage Array ;Affects: A,Y,C,N,Z BLKSWP: JSR MEMSRC ;Set Source Address and Index BLKSWL: JSR BLKDST ;Set Destination Pointer to Block Pointer @@ -295,7 +297,7 @@ BLKSWL: JSR BLKDST ;Set Destination Pointer to Block Pointer ;blksrc() - Set Source Pointer to Block Pointer ;Uses: BLKLO,BLKHI = Block Segment Pointer -;Sets: SRCLO,SRCHI = Source Array Pointer +;Sets: SRCPTR = Source Array Pointer ;Affects: X,N,Z ;Returns: Y = 0 BLKSRC: LDX BLKLO @@ -304,7 +306,7 @@ BLKSRC: LDX BLKLO ;blkdst() - Set Destination Pointer to Block Pointer ;Uses: BLKLO,BLKHI = Block Segment Pointer -;Sets: DSTLO,DSTHI = Destination Array Pointer +;Sets: DSTPTR,DSTPTR+1 = Destination Array Pointer ;Affects: N,Z ;Returns: X = Block Pointer LSB ; Y = Block Pointer MSB @@ -314,7 +316,7 @@ BLKDST: LDX BLKLO ;blkdst() - Set Destination Pointer to Block Start ;Uses: BLKSLO,BLKSHI = Block Start Address -;Sets: DSTLO,DSTHI = Destination Array Pointer +;Sets: DSTPTR,DSTPTR+1 = Destination Array Pointer ;Affects: N,Z ;Returns: X = Block Start LSB ; Y = Block Start MSB @@ -323,25 +325,27 @@ BLKDSS: LDX BLKSLO JMP SETDST ;Set Destination and Return ;Block Debug Routine -BLKDBG: LDA DSTHI +BLKDBG: LDA DSTPTR+1 CMP #$43 BNE BLKDBX - LDA DSTLO + LDA DSTPTR CMP #$57 BNE BLKDBX NOP ;Break Point BLKDBX: RTS ;Print Destination Address -BLKPDA LDA DSTHI ;Print Destination MSB +BLKPDA LDA DSTPTR+1 ;Print Destination MSB JSR PRBYTE - LDA DSTLO ;Print Destination LSB + LDA DSTPTR ;Print Destination LSB JSR PRBYTE JMP PUTSPC ;Print Space ;Print Destination Address -BLKPSA LDA SRCHI ;Print Source MSB +BLKPSA LDA SRCPTR+1 ;Print Source MSB JSR PRBYTE - LDA SRCLO ;Print Source LSB + LDA SRCPTR ;Print Source LSB JSR PRBYTE JMP PUTSPC ;Print Space + + ENDSUBROUTINE diff --git a/py65/testblk.c02 b/test/blktest.c02 similarity index 86% rename from py65/testblk.c02 rename to test/blktest.c02 index 297a67a..88eccd7 100644 --- a/py65/testblk.c02 +++ b/test/blktest.c02 @@ -1,12 +1,13 @@ -/******************************************* - * TESTBLK - Test Array Handling Functions * - *******************************************/ +/***************************************** + * TESTBLK - Test Module block Functions * + *****************************************/ //todo: Test blknxt() and blkprv() -#include +//Specify System Header using -H option #include #include +#include #include #include #include @@ -66,7 +67,7 @@ setchk(&$4321); chkadr(blkhi,blklo); puts("blkset('@'); "); blkset('@'); r=chkptr(&$4321); -while (blkget(1,&sgmt)) {if (sgmt<>'@') r=#FALSE;} psflln(r); +while (blkget(1,&sgmt)) {if (sgmt[0]<>'@') r=#FALSE;} psflln(r); newlin();//if (anykey()==#ESCKEY) goto exit; @@ -99,15 +100,15 @@ puts("blkput(@sgmt, &sgmt);\n"); blkset(0); blkrst(); r = #TRUE; for (i=0; i<10; i++) { printf(i,"%d: "); nsgmt(i,&sgmt); savlo=blklo;savhi=blkhi; blkput(@sgmt,&sgmt); seglo[i]=savlo; seghi[i]=savhi; - putadr(*,savhi,savlo); puts(" _blk="); prtseg(*,savhi,savlo); - setdst(*,savhi,savlo); if (memcmp(@sgmt,&sgmt)) r = #FALSE; + putadr(.,savhi,savlo); puts(" _blk="); prtseg(.,savhi,savlo); + setdst(.,savhi,savlo); if (memcmp(@sgmt,&sgmt)) r = #FALSE; } puts("blkput:"); psflln(r); newlin(); puts("blkget(@temp, &temp);\n"); blkrst(); r = #TRUE; for (i=0; i<10; i++) { printf(i,"%d: "); nsgmt(i,&sgmt); memclr(@temp, &temp); - putadr(*,blkhi,blklo); r = blkget(@temp, &temp); + putadr(.,blkhi,blklo); r = blkget(@temp, &temp); setdst(&temp); if (memcmp(@sgmt, &sgmt)) r = #FALSE; puts(" temp="); prtseg(&temp); } @@ -119,7 +120,7 @@ for (i=9; i:+; i--) { blkmem(@sgmt,&sgmt); if (dstlo<>seglo[i]) r = #FALSE; if (dsthi<>seghi[i]) r = #FALSE; - putadr(*,dsthi,dstlo); puts(" _blk="); prtseg(*,dsthi,dstlo); + putadr(.,dsthi,dstlo); puts(" _blk="); prtseg(.,dsthi,dstlo); } puts("blkmem:"); psflln(r); newlin(); @@ -130,7 +131,7 @@ for (i=0; i<10; i++) { setdst(&temp); blkstr(&sgmt.key); if (srclo<>seglo[i]) r = #FALSE; if (srchi<>seghi[i]) r = #FALSE; - putadr(*,srchi,srclo); puts(" temp="); prtseg(&temp); + putadr(.,srchi,srclo); puts(" temp="); prtseg(&temp); if (memcmp(@sgmt, &sgmt)) r = #FALSE; i++; if (i=9) i=0; //evens then odds } @@ -139,7 +140,7 @@ puts("blkstr:"); psflln(r); anykey(); puts("blksrt(&temp);\n"); r = #TRUE; blksrt(&temp);blkrst(); for (i=0; i<10; i++) { printf(i,"%d: "); nsgmt(sorted[i],&sgmt); memclr(@temp, &temp); - putadr(*,blkhi,blklo); r = blkget(@temp, &temp); + putadr(.,blkhi,blklo); r = blkget(@temp, &temp); setdst(&temp); if (memcmp(@sgmt, &sgmt)) r = #FALSE; puts(" temp="); prtseg(&temp); } @@ -151,16 +152,16 @@ goto exit; char chkptr() { setchk(); //pass through args - putadr(*,blkhi,blklo); - return cmpadr(*,blkhi,blklo); + putadr(.,blkhi,blklo); + return cmpadr(.,blkhi,blklo); } void setchk() { chklo=X; chkhi=Y; } void chkadr(tmphi,tmplo) { - putadr(*,tmphi,tmplo); - cmpadr(*,tmphi,tmplo); + putadr(.,tmphi,tmplo); + cmpadr(.,tmphi,tmplo); psflln(tmplo & tmphi); } @@ -192,7 +193,7 @@ void numstr(n,yy,xx) { strdst(&temp); strcut(mult(n,5),&numbrs); //Copy Representation temp[5] = 0; //Cut off remainder of String z=strchr(' ', &temp); if (z:+) temp[z]=0; //and terminate at space - setdst(*,yy,xx); strcpy(&temp); + setdst(.,yy,xx); strcpy(&temp); } //Build String Segment in Temp @@ -201,7 +202,7 @@ void nsgmt(n,tmphi,tmplo) { numstr(n,&tseg.key); tseg.flag = trufls(n); tseg.value = n; - setdst(*,tmphi,tmplo); memcpy(@tseg,&tseg); + setdst(.,tmphi,tmplo); memcpy(@tseg,&tseg); } //Print Addresses