home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / STRLWR.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.8 KB  |  73 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - strlwr.c
  3.  *
  4.  * function(s)
  5.  *        strlwr - converts a string to lower-case
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma  inline
  18. #include <asmrules.h>
  19. #include <string.h>
  20. #include <ctype.h>
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name            strlwr - converts a string to lower-case
  25.  
  26. Usage           char *strlwr(char *str);
  27.  
  28. Prototype in    string.h
  29.  
  30. Description     strlwr converts upper-case letters in string str to lower-case.
  31.                 No other changes occur.
  32.  
  33. Return value    pointer to the converted string
  34.  
  35. *---------------------------------------------------------------------*/
  36. #if defined(__FARFUNCS__)
  37. #include <_farfunc.h>
  38. #endif
  39.  
  40. char _FAR * _CType _FARFUNC strlwr(char _FAR *s)
  41. {
  42. asm     cld
  43. #if defined(__LARGE__) || defined(__COMPACT__)
  44. asm     push    ds
  45. #endif
  46. asm     LDS_    si, s
  47. asm     mov     dx, si          /* save addr for return */
  48.         goto    next_char;
  49. convert_loop:
  50. asm     sub     al, 'A'         /* see if 'A' .. 'Z' */
  51. asm     cmp     al, 'Z'-'A'
  52. asm     ja      next_char
  53. asm     add     al, 'a'         /* make lowercase */
  54. asm     mov     [si-1], al
  55. next_char:
  56. asm     lodsb
  57. asm     and     al, al
  58. asm     jnz     convert_loop
  59. asm     xchg    ax, dx          /* return addr of string */
  60. #if LDATA
  61. asm     mov     dx, ds
  62. #endif
  63. #if defined(__LARGE__) || defined(__COMPACT__)
  64. asm     pop     ds
  65. #endif
  66.  
  67. #if LDATA
  68.         return((char *)(MK_LONG));
  69. #else
  70.         return((char *)_AX);
  71. #endif
  72. }
  73.