home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s4.arc / UPPERCAS.MOD < prev    next >
Text File  |  1987-11-10  |  5KB  |  72 lines

  1. (*--------------------------------------------------------------------------*)
  2. (*               UpperCase --- Convert string to upper case                 *)
  3. (*--------------------------------------------------------------------------*)
  4.  
  5. FUNCTION UpperCase( S: AnyStr ): AnyStr;
  6.  
  7. (*--------------------------------------------------------------------------*)
  8. (*                                                                          *)
  9. (*    Function: UpperCase                                                   *)
  10. (*                                                                          *)
  11. (*    Purpose:  Convert string to upper case                                *)
  12. (*                                                                          *)
  13. (*    Calling Sequence:                                                     *)
  14. (*                                                                          *)
  15. (*       Upper_String := UpperCase( S : AnyStr ): AnyStr;                   *)
  16. (*                                                                          *)
  17. (*          S            --- String to be converted to upper case           *)
  18. (*          Upper_String --- Resultant uppercase string                     *)
  19. (*                                                                          *)
  20. (*    Calls:  UpCase                                                        *)
  21. (*                                                                          *)
  22. (*    Remarks:                                                              *)
  23. (*                                                                          *)
  24. (*       This routine could be coded directly in Turbo as:                  *)
  25. (*                                                                          *)
  26. (*          VAR                                                             *)
  27. (*              I    : INTEGER;                                             *)
  28. (*              L    : INTEGER;                                             *)
  29. (*              T    : AnyStr;                                              *)
  30. (*                                                                          *)
  31. (*          BEGIN                                                           *)
  32. (*                                                                          *)
  33. (*             L := ORD( S[0] );                                            *)
  34. (*                                                                          *)
  35. (*             FOR I := 1 TO L DO                                           *)
  36. (*                T[I] := UpCase( S[I] );                                   *)
  37. (*                                                                          *)
  38. (*             T[0]      := CHR( L );                                       *)
  39. (*             UpperCase := T;                                              *)
  40. (*                                                                          *)
  41. (*         END;                                                             *)
  42. (*                                                                          *)
  43. (*--------------------------------------------------------------------------*)
  44.  
  45. BEGIN (* UpperCase *)
  46.  
  47. INLINE(
  48.   $1E/                   {         PUSH    DS                ; Save DS}
  49.   $C5/$76/$06/           {         LDS     SI,[BP+6]         ; Get source string address}
  50.   $C4/$7E/$0A/           {         LES     DI,[BP+10]        ; Get result string address}
  51.   $FC/                   {         CLD                       ; Forward direction for strings}
  52.   $AC/                   {         LODSB                     ; Get length of source string}
  53.   $AA/                   {         STOSB                     ; Copy to result string}
  54.   $30/$ED/               {         XOR     CH,CH}
  55.   $88/$C1/               {         MOV     CL,AL             ; Move string length to CL}
  56.   $E3/$0E/               {         JCXZ    Exit              ; Skip if null string}
  57.                          {;}
  58.   $AC/                   {UpCase1: LODSB                     ; Get next source character}
  59.   $3C/$61/               {         CMP     AL,'a'            ; Check if lower-case letter}
  60.   $72/$06/               {         JB      UpCase2}
  61.   $3C/$7A/               {         CMP     AL,'z'}
  62.   $77/$02/               {         JA      UpCase2}
  63.   $2C/$20/               {         SUB     AL,'a'-'A'        ; Convert to uppercase}
  64.                          {;}
  65.   $AA/                   {UpCase2: STOSB                     ; Store in result}
  66.   $E2/$F2/               {         LOOP    UpCase1}
  67.                          {;}
  68.   $1F);                  {Exit:    POP     DS                ; Restore DS}
  69.  
  70.  
  71. END   (* UpperCase *);
  72.