AppleIIAsm-Collection/source/disk5_strings/T.STRINGS.MAC

260 lines
7.0 KiB
Plaintext
Raw Normal View History

2018-11-15 00:02:04 +00:00
*
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
* *
* STRINGS.MAC *
* *
* AUTHOR: NATHAN RIGGS *
* CONTACT: NATHAN.RIGGS@ *
* OUTLOOK.COM *
* *
* VERSION: 0.2.0 *
* DATE: 21-DEC-2018 *
2018-11-15 00:02:04 +00:00
* ASSEMBLER: MERLIN 8 PRO *
* OS: DOS 3.3 *
* LICENSE: APACHE 2.0 *
2018-11-15 00:02:04 +00:00
* *
*------------------------------*
* *
* 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 *
2018-11-15 00:02:04 +00:00
* *
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
*
*``````````````````````````````*
* SCMP : STRING COMPARE *
2018-11-15 00:02:04 +00:00
*- -*
* 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 *
2018-11-15 00:02:04 +00:00
*- -*
* PARAMETERS: *
* *
* ]1 = STRING 1 ADDRESS *
* ]2 = STRING 2 ADDRESS *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SCMP $300;$320 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SCMP MAC
_ISSTR ]1
_ISSTR ]2
2018-11-15 00:02:04 +00:00
JSR STRCMP
<<<
*
*``````````````````````````````*
* SCAT : CONCATENATE STRINGS *
2018-11-15 00:02:04 +00:00
*- -*
* 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 *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SCAT $300;$320;#18 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SCAT MAC
_ISSTR ]1
_ISSTR ]2
2018-11-15 00:02:04 +00:00
LDA ]3 ; MAX SIZE; BYTE
PHA
JSR STRCAT
<<<
*
*``````````````````````````````*
* SPRN : PRINT STRING *
2018-11-15 00:02:04 +00:00
*- -*
* PRINTS THE STRING LOCATED AT *
* THE SPECIFIED ADDRESS, WHICH *
* HAS A PRECEDING LENGTH BYTE. *
*- -*
* PARAMETERS: *
* *
* ]1 = STRING ADDRESS *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SPRN $300 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SPRN MAC
2018-11-15 00:02:04 +00:00
LDA #>]1 ; ADDRESS OF STRING
PHA
LDA #<]1
PHA
JSR PRNSTR
<<<
*
*``````````````````````````````*
* TOSTR : NUMBER TO STRING *
2018-11-15 00:02:04 +00:00
*- -*
* CONVERTS A 16BIT NUMBER TO *
* ITS STRING EQUIVALENT. *
*- -*
* PARAMETERS: *
* *
* ]1 = VALUE TO CONVERT *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* TOSTR #11111 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
TOSTR MAC
_ISLIT ]1
2018-11-15 00:02:04 +00:00
JSR NUM2STR
<<<
*
*``````````````````````````````*
* TONUM : STRING TO NUMBER *
2018-11-15 00:02:04 +00:00
*- -*
* CONVERTS A STRING TO A 16BIT *
* NUMBER EQUIVALENT; RETURNS *
* VALUE IN Y(LOW) AND X(HIGH) *
*- -*
* PARAMETERS: *
* *
* ]1 = ADDR TO STORE VALUE *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* TONUM ????????????? *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
TONUM MAC
_ISSTR ]1
2018-11-15 00:02:04 +00:00
JSR STR2NUM
<<<
*
*``````````````````````````````*
* SPOS : FIND SUBSTRING POS *
2018-11-15 00:02:04 +00:00
*- -*
* POSITION OF SUBSTRING WITHIN *
* ANOTHER STRING IS RETURNED *
* IN Y(LOW) AND X (HIGH) *
*- -*
* PARAMETERS: *
* *
* ]1 = PARENT STRING ADDR *
* ]2 = SUBSTRING ADDR *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SPOS $300;$320 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SPOS MAC
_ISSTR ]1
_ISSTR ]2
2018-11-15 00:02:04 +00:00
JSR SUBPOS
<<<
*
*``````````````````````````````*
* SCPY :: SUBSTRING COPY *
2018-11-15 00:02:04 +00:00
*- -*
* COPY A SUBSTRING FROM A *
* SOURCE STRING TO ANOTHER *
* MEMORY ADDRESS. *
*- -*
* PARAMETERS: *
* *
* ]1 = SOURCE STRING *
* ]2 = STARTING INDEX *
* ]3 = SUBSTRING LENGTH *
* ]4 = MAX LENGTH *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SCPY $300;#1;#10;#20 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SCPY MAC
_ISSTR ]1
2018-11-15 00:02:04 +00:00
LDA ]2 ; STARTING INDEX
PHA
LDA ]3 ; SUBSTRING LENGTH
PHA
LDA ]4 ; MAX LENGTH OF SUBSTR
2018-11-15 00:02:04 +00:00
PHA
JSR SUBCOPY
<<<
*
*``````````````````````````````*
* SDEL :: DELETE SUBSTRING *
2018-11-15 00:02:04 +00:00
*- -*
* DELETE A SUBSTRING FROM A *
* PARENT STRING. ADJUSTS THE *
* STRING LENGTH ACCORDINGLY. *
*- -*
* PARAMETERS: *
* *
* ]1 = PARENT STRING ADDR *
* ]2 = STARTING INDEX *
* ]3 = DELETION LENGTH *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SDEL $300;#3;#10 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SDEL MAC
2018-11-15 00:02:04 +00:00
LDA #>]1 ; STRING ADDRESS
PHA
LDA #<]1
PHA
LDA ]2 ; INDEX BYTE
PHA
LDA ]3 ; LENGTH
PHA
JSR SUBDEL
<<<
*
*``````````````````````````````*
* SINS :: INSERT SUBSTRING *
2018-11-15 00:02:04 +00:00
*- -*
* INSERT A SUBSTRING INTO A *
* PARENT STRING. *
*- -*
* PARAMETERS: *
* *
* ]1 = PARENT STRING *
* ]2 = INDEX *
* ]3 = MAX LENGTH OF NEW *
* ]4 = SUBSTRING *
2018-11-15 00:02:04 +00:00
*- -*
* SAMPLE USAGE: *
* SINS $300;#1;#254;$6000 *
2018-11-15 00:02:04 +00:00
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SINS MAC
2018-11-15 00:02:04 +00:00
LDA #>]1 ; PARENT STRING
PHA
LDA #<]1
PHA
LDA ]2 ; INDEX
PHA
LDA ]3 ; MAXIMUM LENGTH
PHA
_ISSTR ]4
2018-11-15 00:02:04 +00:00
JSR SUBINS
<<<