* *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=* * * * STRINGS.MAC * * * * AUTHOR: NATHAN RIGGS * * CONTACT: NATHAN.RIGGS@ * * OUTLOOK.COM * * * * VERSION: 0.2.0 * * DATE: 21-DEC-2018 * * ASSEMBLER: MERLIN 8 PRO * * OS: DOS 3.3 * * LICENSE: APACHE 2.0 * * * *------------------------------* * * * THIS IS A MACRO LIBRARY FOR * * THE 8BIT STRING LIBRARIES, * * STRINGS.LIB & SUBSTRINGS.LIB * * * *------------------------------* * * * LIST OF MACROS * * * * SCMP : STRING COMPARE * * SCAT : STRING CONCATENATE * * SPRN : PRINT STRING * * TOSTR : NUMBER TO STRING * * TONUM: STRING TO NUMBER * * SPOS : FIND SUBSTRING POS * * SCOP : SUBSTRING COPY * * SDEL : SUBSTRING DELETE * * SINS : SUBSTRING INSERT * * * *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=* * *``````````````````````````````* * SCMP : STRING COMPARE * *- -* * COMPARE TWO STRINGS AND * * DETERMINE IF IDENTICAL, OR * * LONGER AND SHORTER. * * * * .Z=1 IF IDENTICAL; 0 IF NOT * * .C=1 IF STR2 > STR1 * * .C=0 IF STR1 > STR2 LENGTH * *- -* * PARAMETERS: * * * * ]1 = STRING 1 ADDRESS * * ]2 = STRING 2 ADDRESS * *- -* * SAMPLE USAGE: * * SCMP $300;$320 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SCMP MAC _ISSTR ]1 _ISSTR ]2 JSR STRCMP <<< * *``````````````````````````````* * SCAT : CONCATENATE STRINGS * *- -* * CONCATENATES STRING 1 AND * * STRING 2, STORED AT THE * * ADDRESS OF STRING 1. * *- -* * PARAMETERS: * * * * ]1 = ADDR OF STRING 1 * * ]2 = ADDR OF STRING 2 * * ]3 = MAX LEN OF NEW STRING * *- -* * SAMPLE USAGE: * * SCAT $300;$320;#18 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SCAT MAC _ISSTR ]1 _ISSTR ]2 LDA ]3 ; MAX SIZE; BYTE PHA JSR STRCAT <<< * *``````````````````````````````* * SPRN : PRINT STRING * *- -* * PRINTS THE STRING LOCATED AT * * THE SPECIFIED ADDRESS, WHICH * * HAS A PRECEDING LENGTH BYTE. * *- -* * PARAMETERS: * * * * ]1 = STRING ADDRESS * *- -* * SAMPLE USAGE: * * SPRN $300 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SPRN MAC LDA #>]1 ; ADDRESS OF STRING PHA LDA #<]1 PHA JSR PRNSTR <<< * *``````````````````````````````* * TOSTR : NUMBER TO STRING * *- -* * CONVERTS A 16BIT NUMBER TO * * ITS STRING EQUIVALENT. * *- -* * PARAMETERS: * * * * ]1 = VALUE TO CONVERT * *- -* * SAMPLE USAGE: * * TOSTR #11111 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * TOSTR MAC _ISLIT ]1 JSR NUM2STR <<< * *``````````````````````````````* * TONUM : STRING TO NUMBER * *- -* * CONVERTS A STRING TO A 16BIT * * NUMBER EQUIVALENT; RETURNS * * VALUE IN Y(LOW) AND X(HIGH) * *- -* * PARAMETERS: * * * * ]1 = ADDR TO STORE VALUE * *- -* * SAMPLE USAGE: * * TONUM ????????????? * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * TONUM MAC _ISSTR ]1 JSR STR2NUM <<< * *``````````````````````````````* * SPOS : FIND SUBSTRING POS * *- -* * POSITION OF SUBSTRING WITHIN * * ANOTHER STRING IS RETURNED * * IN Y(LOW) AND X (HIGH) * *- -* * PARAMETERS: * * * * ]1 = PARENT STRING ADDR * * ]2 = SUBSTRING ADDR * *- -* * SAMPLE USAGE: * * SPOS $300;$320 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SPOS MAC _ISSTR ]1 _ISSTR ]2 JSR SUBPOS <<< * *``````````````````````````````* * SCPY :: SUBSTRING COPY * *- -* * COPY A SUBSTRING FROM A * * SOURCE STRING TO ANOTHER * * MEMORY ADDRESS. * *- -* * PARAMETERS: * * * * ]1 = SOURCE STRING * * ]2 = STARTING INDEX * * ]3 = SUBSTRING LENGTH * * ]4 = MAX LENGTH * *- -* * SAMPLE USAGE: * * SCPY $300;#1;#10;#20 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SCPY MAC _ISSTR ]1 LDA ]2 ; STARTING INDEX PHA LDA ]3 ; SUBSTRING LENGTH PHA LDA ]4 ; MAX LENGTH OF SUBSTR PHA JSR SUBCOPY <<< * *``````````````````````````````* * SDEL :: DELETE SUBSTRING * *- -* * DELETE A SUBSTRING FROM A * * PARENT STRING. ADJUSTS THE * * STRING LENGTH ACCORDINGLY. * *- -* * PARAMETERS: * * * * ]1 = PARENT STRING ADDR * * ]2 = STARTING INDEX * * ]3 = DELETION LENGTH * *- -* * SAMPLE USAGE: * * SDEL $300;#3;#10 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SDEL MAC LDA #>]1 ; STRING ADDRESS PHA LDA #<]1 PHA LDA ]2 ; INDEX BYTE PHA LDA ]3 ; LENGTH PHA JSR SUBDEL <<< * *``````````````````````````````* * SINS :: INSERT SUBSTRING * *- -* * INSERT A SUBSTRING INTO A * * PARENT STRING. * *- -* * PARAMETERS: * * * * ]1 = PARENT STRING * * ]2 = INDEX * * ]3 = MAX LENGTH OF NEW * * ]4 = SUBSTRING * *- -* * SAMPLE USAGE: * * SINS $300;#1;#254;$6000 * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * SINS MAC LDA #>]1 ; PARENT STRING PHA LDA #<]1 PHA LDA ]2 ; INDEX PHA LDA ]3 ; MAXIMUM LENGTH PHA _ISSTR ]4 JSR SUBINS <<<