home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / sampler / 02 / zd_etc / ucasestr.asm < prev    next >
Encoding:
Assembly Source File  |  1988-01-21  |  1.3 KB  |  58 lines

  1.     title UCASESTR
  2. CODE segment byte public
  3.     assume   cs:code
  4.     public   UCASESTR
  5.  
  6. ; procedure UcaseStr(var S);
  7. UCASESTR proc far
  8.     Str       equ dword ptr [bp+6]
  9.     StackSize equ 4
  10.  
  11.     push   bp       ;save bp & ds
  12.     mov    bp,sp
  13.     push   ds
  14.  
  15.     lds si, Str     ;ds:si is ptr to S
  16.     xor cx,cx       ;clear cx
  17.     mov cl, [si]    ;length of S
  18.  
  19.     jcxz    NullStr ;0 length, skip
  20.  
  21.     inc si          ;pt to char 1
  22.                     ;as STOSB writes to ds:[ei], copy ds:[si] to es:[di]
  23.     mov di,si
  24.     mov ax,ds
  25.     mov es,ax
  26.     mov bx, 'za'    ;faster compares in registers
  27.     mov ah, 020h    ;for XORing 5th bit
  28.  
  29.     ;we now have:
  30.     ;    ds:[si] & es:[di] both pt to S[1]
  31.     ;    bx contains 'za'
  32.     ;    ah contains 10h
  33.     ;    cx contains length of S
  34.     cld             ;as Karl says, try this
  35. DoIt:
  36.     lodsb           ;[si] to al
  37.     cmp   al, bl    ;al ? 'a'
  38.     jl    NoChange  ; its <
  39.     cmp   al, bh    ;al ? 'z'
  40.     jg    NoChange  ; its >
  41.     xor   al, ah    ;turno bit 5 off
  42.     stosb           ;save it back
  43.     jmp   DoneYet
  44. NoChange:
  45.     inc   di        ;no stosb done
  46. DoneYet:
  47.     loop  DoIt      ;any more chars
  48.  
  49. NullStr:
  50. Exit:
  51.     pop ds          ;restore ds & bp
  52.     pop bp
  53.     ret StackSize   ;clean stack params
  54.  
  55. UCASESTR endp
  56. CODE     ends
  57.     end
  58.