home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / tools / conv_a11 / uc.asm < prev    next >
Assembly Source File  |  1989-11-06  |  1KB  |  61 lines

  1. ;String uppercasing function.
  2. ;
  3. ;Declare as follows:
  4. ;    {$F+}
  5. ;    {$L UC.OBJ}
  6. ;    FUNCTION Uc(S : STRING) : STRING; EXTERNAL;
  7. ;Call as follows:
  8. ;    Uppercased := Uc(S);
  9. ;
  10. ;Courtesy of Toad Hall
  11.  
  12. ;Total stack (caller's plus work stack)
  13. cstk    STRUC
  14. bpsave    DW    0            ;save BP here
  15. retaddr    DD    0            ;points to return address
  16. straddr    DD    0            ;points to string address
  17. strptr    DD    0            ;ptr to temporary string location
  18. cstk    ENDS
  19.  
  20. PARAMSIZE    EQU SIZE straddr    ;size of parameter list
  21.  
  22. PUBLIC    Uc                ;function name declaration
  23.  
  24. CODE    SEGMENT PARA PUBLIC 'CODE'
  25.     ASSUME    CS:CODE
  26.  
  27. ;Entry point to Uc function
  28. Uc    PROC    FAR
  29.     push    bp
  30.     mov    bp,sp
  31.  
  32.     mov    bx,DS            ;save caller's DS
  33.     cld
  34.  
  35.     lds    si,[bp.straddr]        ;target string
  36.     les    di,[bp.strptr]        ;ptr to temporary string buffer
  37.     lodsb                ;get string length
  38.     stosb                ;stuff as output str length
  39.     or    al,al            ;if string text is null
  40.     jz    Exit            ; then exit
  41.  
  42.     xor    ah,ah            ;clear msb
  43.     mov    cx,ax            ;loop counter
  44.     mov    dx,2061H        ;DL='a',DH=20H
  45. L1:    lodsb                ;next char
  46.     cmp    al,dl
  47.     jb    S1            ;already uppercase
  48.      sub    al,dh            ;uppercase it
  49. S1:    stosb                ;stuff uppercased char
  50.     loop    L1
  51.  
  52. Exit:    mov    DS,bx            ;restore caller's DS
  53.     mov    sp,bp            ;recover last stack psn
  54.     pop    bp            ;recover BP
  55.     ret    PARAMSIZE        ;return
  56.  
  57. Uc    ENDP
  58.  
  59. CODE    ENDS
  60.     END    Uc
  61.