     1                                  ;*********************************************************************
     2                                  ;*   MLGETARG.ASM                                                    *
     3                                  ;*                                                                   *
     4                                  ;*   By:            Michael Devore                                   *
     5                                  ;*   Date:          12/02/90                                         *
     6                                  ;*   Model:         Small                                            *
     7                                  ;*   Version:       1.0                                              *
     8                                  ;*   Assembler:     MASM 5.0                                         *
     9                                  ;*   Environment:   MS-DOS 2.x+                                      *
    10                                  ;*                                                                   *
    11                                  ;*   get command line arguments                                      *
    12                                  ;*                                                                   *
    13                                  ;*********************************************************************
    14                                  
    15                                  ;TITLE   MACHLINK
    16                                  ;PAGE    50,80
    17                                  
    18                                  ;.MODEL  SMALL
    19                                  
    20                                  ;*****************************
    21                                  ;* Include files             *
    22                                  ;*****************************
    23                                  
    24                                  [list -]
    28                                       
    29                                  ;*****************************
    30                                  ;* Public declarations       *
    31                                  ;*****************************
    32                                       
    33                                  PUBLIC  getargs
    34                                  
    35                                  ;*****************************
    36                                  ;* Code begins               *
    37                                  ;*****************************
    38                                  
    39                                  .CODE
    40                                  
    41                                  getargs     PROC
    42 00000000 8CC0                        mov ax,es               ; swap extra segment, data segment
    43 00000002 8CDB                        mov bx,ds
    44 00000004 8ED8                        mov ds,ax
    45 00000006 8EC3                        mov es,bx               ; es -> linker data, ds -> PSP
    46 00000008 BE8000                      mov si,80h              ; si -> command line offset
    47 0000000B BF[0000]                    mov di,OFFSET cmd_line wrt DGROUP   ; di -> linker data command line location
    48 0000000E 8A0C                        mov cl,[si]             ; get count of bytes in command line
    49 00000010 30ED                        xor ch,ch               ; zap high byte of count
    50 00000012 E318                        jcxz    ga2             ; no arguments on command line
    51                                  
    52                                  ; check for one char as space, in case of i/o redirection of summary
    53 00000014 80F901                      cmp cl,1
    54 00000017 7506                        jne ga_1                ; more than one character
    55 00000019 807C0120                    cmp BYTE PTR [si+1],' ' ; see if character is whitespace
    56 0000001D 760D                        jbe ga2                 ; yes, no arguments on command line
    57                                  
    58                                  ga_1:
    59 0000001F A4                          movsb                   ; transfer byte count of command tail in PSP
    60 00000020 FEC1                        inc cl                  ; account for return character in command tail
    61 00000022 F3A4                        rep movsb               ; transfer command tail and terminating return character
    62 00000024 8EDB                        mov ds,bx               ; ds -> linker data
    63 00000026 C606[0000]01                mov byte [is_args],1           ; flag that command line argument(s) exist
    64 0000002B C3                          ret
    65                                  ga2:
    66 0000002C 8EDB                        mov ds,bx               ; ds -> linker data
    67 0000002E C3                          ret
    68                                  getargs     ENDP
    69                                  
    70                                  END
    71                                  
