home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / TASMSWAN.ZIP / UPDOWN.C < prev    next >
Text File  |  1989-07-17  |  1KB  |  62 lines

  1. /******************************************************************
  2. updown.c
  3.     an in-line assembly language Function example
  4.        NOTE: you must use the TCC comand-line compiler for this !
  5. ********/
  6.  
  7. #pragma inline
  8. #include <stdio.h>
  9.  
  10. extern void BumpStrUp(unsigned char far * TheString, int StringLength);
  11. extern void BumpStrDown(unsigned char far * TheString, int StringLength);
  12.  
  13. char *MixedUp = "UppER aNd LOwEr CaSE";
  14.  
  15. main()
  16. {
  17.     printf("Before BumpStrUp: %s\n", MixedUp);
  18.     BumpStrUp(MixedUp, strlen(MixedUp) );
  19.     printf("After BumpStrUp:   %s\n", MixedUp);
  20.     BumpStrDown( MixedUp, strlen(MixedUp) );
  21.     printf("After BumpStrDown: %s\n", MixedUp);
  22. }
  23.  
  24. void BumpStrUp(unsigned char far * TheString, int StringLength)
  25. {
  26.     asm     les     di,TheString
  27.     asm    mov    cx,StringLength
  28.     asm    jcxz    Exit
  29.     asm    cld
  30. NextChar:
  31.     asm    mov    al, [Byte ptr es:di]
  32.     asm    cmp    al, 'a'
  33.     asm    jb    NotLower
  34.     asm    cmp    al,'z'
  35.     asm    ja    NotLower
  36.     asm    sub    al,32
  37. NotLower:
  38.     asm    stosb
  39.     asm    loop    NextChar
  40. Exit:;
  41. }
  42.  
  43.  
  44. void BumpStrDown(unsigned char far * TheString, int StringLength)
  45. {
  46.     asm     les     di,TheString
  47.     asm    mov    cx,StringLength
  48.     asm    jcxz    Exit
  49.     asm    cld
  50. NextChar:
  51.     asm    mov    al, [Byte ptr es:di]
  52.     asm    cmp    al, 'A'
  53.     asm    jb    NotUpper
  54.     asm    cmp    al,'Z'
  55.     asm    ja    NotUpper
  56.     asm    add    al,32
  57. NotUpper:
  58.     asm    stosb
  59.     asm    loop    NextChar
  60. Exit:;
  61. }
  62.