home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / STRUPR.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.1 KB  |  71 lines

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