1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| getparam proc
;; copy filename from DOS command line to ds:di
push ds ; We push ds to save it for the end
push ds ; We push ds to swap it to ES
pop es ; We pop ES to set it to DS
mov ah,62h ; We call the 62h function
int 21h ; Of the INT21h to get address of program segment prefix
mov ds,bx ; We set ds to the PSP segment
mov si,80h ; The command line arguments begin at 80h of the PSP
mov cl,[si] ; get character count of cmd line args
cmp cl,0
je getparam_exit ; exit if no filename
inc si ; point at first character
skipspace: ; We check for spaces to begin to read params
mov al,[si]
cmp al,20h ; Is it a space?
jne getstring ; No, we begin to read the string
inc si ; It's a space, we increment to check following char
dec cl ; Number of char to read will be decremented
jmp skipspace ; We loop to check other spaces
getstring:
cld ; No more interrupts
rep movsb ; We loop on a movsb to read a full string (copies from DS:SI to ES:DI)
inc di ; We increment di to set the string terminated char
mov BYTE PTR es:[di], 24h ; We set a $ as last char to terminate the string
getparam_exit:
pop ds ; We restore data segment
ret ; We exit the getparam function
getparam endp |
Partager