home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / TASMSWAN.ZIP / STR.ASM < prev    next >
Assembly Source File  |  1989-07-17  |  1KB  |  61 lines

  1. %TITLE "ASCIIZ and Turbo Pascal String conversions"
  2.  
  3.     IDEAL
  4.     MODEL    TPASCAL
  5.  
  6.     CODESEG
  7.  
  8.     PUBLIC    ASCIIZtoStr, StrToASCIIZ
  9.  
  10. %NEWPAGE
  11. ;------------------------------------------------------------------------
  12. ;  PROCEDURE ASCIIZtoStr( a : ASCIIZString; VAR s : String )
  13. ;------------------------------------------------------------------------
  14. PROC    ASCIIZtoStr    NEAR
  15.     ARG a:dword, s:dword = ArgSize
  16.     push    ds
  17.     les    di,[s]
  18.     push    di
  19.     inc    di
  20.     lds    si,[a]
  21.     cld
  22.     xor    cl,cl
  23. @@10:
  24.     cmp    cl,255
  25.     je    @@20
  26.     lodsb
  27.     or    al,al
  28.     jz    @@20
  29.     inc    cl
  30.     stosb
  31.     jmp    @@10
  32. @@20:
  33.     pop    di
  34.     mov    [byte es:di], cl
  35.     pop    ds
  36.     ret
  37. ENDP    ASCIIZtoStr
  38.  
  39. %NEWPAGE
  40. ;--------------------------------------------------------------------
  41. ;  PROCEDURE StrToASCIIZ( s : String; VAR a : ASCIIZString );
  42. ;--------------------------------------------------------------------
  43. PROC    StrToASCIIZ    NEAR
  44.     ARG s:dword, a:dword = ArgSize
  45.     push    ds
  46.     les    di,[a]
  47.     lds    si,[s]
  48.     cld
  49.     xor    ch,ch
  50.     lodsb
  51.     mov    cl,al
  52.     jcxz    @@10
  53.     repnz    movsb
  54. @@10:
  55.     mov    [byte es:di], cl
  56.     pop    ds
  57.     ret
  58. ENDP    StrToASCIIZ
  59.  
  60.     END
  61.