home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / strings.swg / 0025_Fast-Small Upper-Low Case.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-23  |  994 b   |  63 lines

  1.  
  2. { VERY FAST AND SMALL UP/LOW CASE}
  3. { BY BRAIN PAPE }
  4.  
  5. Uses CRT;
  6.  
  7.   function LoStr(const s:string):string; assembler;
  8.   asm
  9.     push ds
  10.     lds  si,s
  11.     les  di,@result
  12.     lodsb            { load and store length of string }
  13.     stosb
  14.     xor  ch,ch
  15.     mov  cl,al
  16.     @LowerLoop:
  17.     lodsb
  18.     cmp  al,'A'
  19.     jb   @cont
  20.     cmp  al,'Z'
  21.     ja   @cont
  22.     add  al,' '
  23.     @cont:
  24.     stosb
  25.     loop @LowerLoop
  26.     pop  ds
  27.   end;  { LoStr }
  28.  
  29.   function UpStr(const s:string):string; assembler;
  30.   asm
  31.     push ds
  32.     lds  si,s
  33.     les  di,@result
  34.     lodsb            { load and store length of string }
  35.     stosb
  36.     xor  ch,ch
  37.     mov  cl,al
  38.     @upperLoop:
  39.     lodsb
  40.     cmp  al,'a'
  41.     jb   @cont
  42.     cmp  al,'z'
  43.     ja   @cont
  44.     sub  al,' '
  45.     @cont:
  46.     stosb
  47.     loop @UpperLoop
  48.     pop  ds
  49.   end;  { UpStr }
  50.  
  51. VAR S : String;
  52.  
  53. BEGIN
  54. ClrScr;
  55. WriteLn(LoStr('GAYLE DAVIS'));
  56. WriteLn(UpStr('gayle davis'));
  57. Readkey;
  58. END.
  59.  
  60.  
  61.  
  62.  
  63.