home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l040 / 13.ddi / RTLSYS.ZIP / WPAR.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-10-28  |  1.5 KB  |  108 lines

  1.  
  2. ; *******************************************************
  3. ; *                            *
  4. ; *     Turbo Pascal Run-time Library                   *
  5. ; *    Windows Command Line Parameter Routines        *
  6. ; *                            *
  7. ; *     Copyright (c) 1988,92 Borland International     *
  8. ; *                            *
  9. ; *******************************************************
  10.  
  11.     TITLE    WPAR
  12.  
  13.     INCLUDE    SE.ASM
  14.  
  15. DATA    SEGMENT    WORD PUBLIC
  16.  
  17. ; Externals
  18.  
  19.     EXTRN    HInstance:WORD,CmdLine:DWORD
  20.  
  21. DATA    ENDS
  22.  
  23. ; Windows entry points
  24.  
  25.     EXTRN    GetModuleFileName:FAR
  26.  
  27. CODE    SEGMENT    BYTE PUBLIC
  28.  
  29.     ASSUME    CS:CODE,DS:DATA
  30.  
  31. ; Publics
  32.  
  33.     PUBLIC    GetParStr,GetParCnt
  34.  
  35. ; ParamStr standard function
  36.  
  37. GetParStr:
  38.  
  39.     ARG    StrP,DWORD,1
  40.     ARG    Index,WORD,1
  41.  
  42.     ENTRY    WINFAR
  43.     MOV    CX,Index
  44.     JCXZ    @@1
  45.     PUSH    DS
  46.     CALL    ParStrCnt
  47.     MOV    SI,BX
  48.     LES    DI,StrP
  49.     STOSB
  50.     XCHG    AX,CX
  51.     REP    MOVSB
  52.     POP    DS
  53.     JMP    SHORT @@2
  54. @@1:    PUSH    HInstance
  55.     LES    DI,StrP
  56.     INC    DI
  57.     PUSH    ES
  58.     PUSH    DI
  59.     MOV    AX,255
  60.     PUSH    AX
  61.     CALL    GetModuleFileName
  62.     LES    DI,StrP
  63.     STOSB
  64. @@2:    EXIT    2
  65.  
  66. ; ParamCount standard function
  67.  
  68. GetParCnt:
  69.  
  70.     PUSH    DS
  71.     XOR    CX,CX
  72.     CALL    ParStrCnt
  73.     XCHG    AX,CX
  74.     NEG    AX
  75.     POP    DS
  76.     RETF
  77.  
  78. ; Return parameter string and count
  79. ; In    CX    = Parameter string number
  80. ; Out    AX    = Parameter string length
  81. ;    CX    = Negative parameter string count
  82. ;    DS:BX = Parameter string pointer
  83.  
  84. ParStrCnt:
  85.  
  86.     LDS    SI,CmdLine
  87.     CLD
  88. @@1:    LODSB
  89.     OR    AL,AL
  90.     JE    @@2
  91.     CMP    AL,' '
  92.     JBE    @@1
  93. @@2:    DEC    SI
  94.     MOV    BX,SI
  95. @@3:    LODSB
  96.     CMP    AL,' '
  97.     JA    @@3
  98.     DEC    SI
  99.     MOV    AX,SI
  100.     SUB    AX,BX
  101.     JE    @@4
  102.     LOOP    @@1
  103. @@4:    RET
  104.  
  105. CODE    ENDS
  106.  
  107.     END
  108.