home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / bluebook.zip / STRINGS.DOC < prev    next >
Text File  |  1986-05-08  |  10KB  |  214 lines

  1. STRINGS.DOC -- Description of Routines in STRINGS.ASM
  2. =====================================================
  3.  
  4.   From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
  5.         by Christopher L. Morgan
  6.         Copyright (C) 1984 by The Waite Group, Inc.
  7.  
  8.    Purpose: The routines in STRINGS.ASM are used to manipulate strings.
  9.  
  10.    Contents:
  11.    ---------
  12.    COMPARE    --  Compare two strings
  13.    LEXINSERT    --  Lexigraphically insert
  14.    LEXSEARCH    --  Search a lexigraphically ordered list
  15.    LOWERCASE    --  Convert to lower case
  16.    SORTB    --  Bubble sort a string array
  17.    STRINSERT    --  Insert one string in another
  18.    STRSEARCH    --  Search for one string within another
  19.    SWITCH    --  Switch two strings
  20.    UPPERCASE    --  Convert to upper case
  21.  _______________________________________________________________________________
  22.  
  23.    Overview:
  24.    ---------
  25.      LOWERCASE & UPPERCASE convert characters within a string to the other
  26.    case.
  27.        STRSEARCH & STRINSERT require two input strings.  STRSEARCH searches
  28.    for a copy of one string in another, and STRINSERT inserts a copy of one
  29.    string within another.
  30.       LEXSEARCH & LEXINSERT require a string and a LIST of strings as input.
  31.    LEXSEARCH searches for the proper place to insert a string in a
  32.    lexigraphically-ordered list of strings  LEXINSERT inserts a string in the
  33.    proper place in a lexigraphically-ordered list of strings. Lexigraphic is
  34.    the same as alphabetic, except these routines are ordered according to their
  35.    ASCII code.  So all uppercase letters precede any lowercase letter.
  36.    These procedures can easily be modified so all lowercase letters are first
  37.    converted to uppercase before lexigraphic comparison.
  38.       LEXINSERT calls LEXSEARCH to find the proper spot, then calls
  39.    STRINSERT to make the insertion.
  40.      COMPARE, SWITCH, AND SORTB work with string arrays.  COMPARE compares
  41.    two strings of equal length.  It lets you compare two different entries of
  42.    the same string array. SWITCH switches two strings of the same length  e.g.,
  43.    two different entries of the same string array.  Both these routines are
  44.    needed by SORTB, which performs a bubble sort of a string array.  
  45.      These routines take advantage of the 8088 string instructions.
  46.  
  47. _____________________________ROUTINE DESCRIPTIONS______________________________
  48.  
  49. LOWERCASE -- Convert to Lower Case
  50.  
  51.   Function: This routine converts the characters in a string to lower case.
  52.  
  53.   Input: Upon entry, DS:BX points to a string.  The first two bytes in the 
  54.     string form a 16-bit integer which specifies its length.  The remaining
  55.     bytes contain the characters of the string.
  56.  
  57.   Output: Upon exit, all alphabetical characters of the string are lower case.
  58.  
  59.   Registers used: AX, BX, & CX are first saved and then restored.
  60.  
  61.   Segments referenced: Upon entry, the data segment must contain the string.
  62. _______________________________________________________________________________
  63.  
  64. UPPERCASE -- Convert to Upper Case
  65.  
  66.   Function: This routine converts the characters in a string to upper case.
  67.  
  68.   Input: Upon entry, DS:BX points to a string.  The first two bytes in the 
  69.     string form a 16-bit integer which specifies its length.  The remaining
  70.     bytes contain the characters of the string.
  71.  
  72.   Output: Upon exit, all alphabetical characters of the string are upper case.
  73.  
  74.   Registers used: AX, BX, & CX are first saved and then restored.
  75.  
  76.   Segments referenced: Upon entry, the data segment must contain the string.
  77. _______________________________________________________________________________
  78.  
  79. STRSEARCH -- Search for One String Within Another
  80.  
  81.   Function: This routine searches for a copy of a source string within a
  82.     destination string.
  83.  
  84.   Input: Upon entry, DS:BX points to a source string and ES:DX points to a
  85.     destination string.  Each string begins with a 16-bit integer that
  86.     specifies its length.
  87.  
  88.   Output: Upon exit, AL contains a return flag (0=not found, 0FFH=found), and
  89.     if the search was successful DX contains the location of the first byte of
  90.     the match in the destination.
  91.  
  92.   Registers used: AX & DX are used for output; all others are unmodified.
  93.  
  94.   Segments referenced: Upon entry, the data segment must contain the source
  95.     string and the extra segment must contain the destination string.
  96. _______________________________________________________________________________
  97.  
  98. STRINSERT -- Insert One String in Another
  99.  
  100.   Function: This routine inserts a source string in a specified spot in a 
  101.     destination string.
  102.  
  103.   Input: Upon entry, DS:BX points to the source string, ES:BP points to the
  104.     destination string, and ES:DX points to the spot in the destination where
  105.     the source is to be placed. Each string begins with a 16-bit integer that
  106.     begins with a 16-bit integer specifying its length.
  107.  
  108.   Output: Upon exit, the destination string has the source string inserted in
  109.     the proper location.  The length of the destination string is increased
  110.     accordingly.
  111.  
  112.   Registers used: SI, DI, CX, & AX are first saved and then restored.
  113.  
  114.   Segments referenced: Upon entry, the data segment must contain the source
  115.     string and the extra segment must contain the destination string.
  116. _______________________________________________________________________________
  117.  
  118. LEXSEARCH -- Search a Lexigraphically Ordered List
  119.  
  120.   Function: This routine searches a lexigraphically (alphabetically) ordered
  121.     list of word strings for the proper place to insert a new word.
  122.  
  123.   Input: Upon entry, DS:BX points to a source word string, ES:BP points to the
  124.     ordered list of words. The source word string begins with a 16-bit integer
  125.     that is its length and is followed by the bytes of the string.  The last
  126.     byte must be a <CR> (ASCII 13). The destination list of words begins with
  127.     a 16-bit integer specifying its length, continuing with the words which
  128.     must consist of ASCII characters.  The words in the list are separated by
  129.     <CR>'s (ASCII 13).
  130.  
  131.   Output: Upon exit, AL contains a return flag (0=not found, 0FFH=found). If
  132.     the search was successful, ES:DX contains the location of the proper place
  133.     to insert the new word. If the word was already present, then ES:DX points
  134.     to the location of this word in the destination.
  135.  
  136.   Registers used: AX & DX are used for output; all else is unmodified.
  137.  
  138.   Segments referenced: Upon entry, the data segment must contain the source
  139.     string and the extra segment must contain the destination word list.
  140. _______________________________________________________________________________
  141.  
  142. LEXINSERT -- Lexigraphically Insert
  143.  
  144.   Function: This routine inserts a word string in the proper place in a
  145.     lexigraphically (alphabetically) ordered list of word strings.  If the
  146.     word is already present, no insertion occurs.
  147.  
  148.   Input: Upon entry, DS:BX points to a source word string and ES:BP points to 
  149.     the ordered list of words. The source word string begins with a 16-bit 
  150.     integer specifying its length.  The string is ASCII and must be terminated
  151.     by a <CR> symbol (ASCII 13). The destination list of words begins with a
  152.     16-bit integer specifying its length and continues with words consisting
  153.     of ASCII characters. The words are separated by <CR> symbols (ASCII 13).
  154.  
  155.   Output: Upon exit, the list has the string inserted in the proper place.
  156.  
  157.   Registers used: AX is first saved and then restored.
  158.  
  159.   Segments referenced: Upon entry, the data segment and the extra segment must
  160.     be equal and must contain the source string and the destination word list.
  161. _______________________________________________________________________________
  162.  
  163. COMPARE -- Compare Two Strings
  164.  
  165.   Function: This routine compares two strings of the same length.
  166.  
  167.   Input: Upon entry, DS:SI points to one string (source) and DS:DI points to
  168.     the second string (destination). Both strings have lengths given by CX.
  169.  
  170.   Output: Upon exit, the flags show the relation of the source to destination:
  171.  
  172.             L = source string is less than destination string
  173.         E = source string is equal to the destination string
  174.             G = source string is greater than the destination string    
  175.  
  176.   Registers used: AX is modified.
  177.  
  178.   Segments referenced: Upon entry, the data segment contains the source string
  179.     and the extra segment contains the destination string.
  180. _______________________________________________________________________________
  181.  
  182. SWITCH -- Switch Two Strings
  183.  
  184.   Function: This routine switches two strings of equal length.
  185.  
  186.   Input: Upon entry, DS:SI points to one string (source) and ES:DI points to
  187.     the second string (destination). Both strings have lengths given by CX.
  188.  
  189.   Output: Upon exit, the strings are switched.
  190.  
  191.   Registers used: AX, CX, DI, & SI are first saved and then restored
  192.  
  193.   Segments referenced: Upon entry, the data segment contains the source and the
  194.     extra segment contains the destination string.
  195. _______________________________________________________________________________
  196.  
  197. SORTB -- Bubble Sort a String Array
  198.  
  199.   Function: This routine sorts a string array using bubble sort.
  200.  
  201.   Input: Upon entry, DS:SI points to a string array, CX contains the number of
  202.     entries in the array, and DX contains the size of each entry.
  203.  
  204.   Output: Upon exit, the array is alpha-up sorted. 
  205.  
  206.   Registers used: AX, CX, DI, & SI are first saved and then restored
  207.  
  208.   Segments referenced: Upon entry, the data segment and the extra segment must
  209.     be equal and must contain the string array.
  210.  
  211.   Routines called: COMPARE, SWITCH
  212. _______________________________________________________________________________
  213. >>>>> Physical EOF STRINGS.ASM <<<<<
  214.