*
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
*                              *
* 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         *
*  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
         _ISLIT ]1
         JSR   PRNSTR
         <<<
*
*``````````````````````````````*
* 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
         _ISLIT ]1
         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
         _ISLIT ]1
         LDA   ]2         ; INDEX
         PHA
         LDA   ]3         ; MAXIMUM LENGTH
         PHA
         _ISSTR ]4
         JSR   SUBINS
         <<<
