home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
sysutl
/
parapass.arc
/
PARAPASS.8
next >
Wrap
Text File
|
1988-05-31
|
18KB
|
387 lines
; PROGRAM : parapass
;
; VERSION : 0.0 (BETA TEST) 10/20/87
;
; INVOCATION : parapass <program name> </q>
; the /q option is quiet option, it won't prompt for
; parameters but will wait to read them
;
; AUTHOR : Rusty Baldwin
; 4783 W. 133rd St. #12
; Hawthorne, CA 90250
;
; LANGUAGE : This program was developed with the A86 assembly language
; if you want to assemble using MASM your on your own.
; To assemble using A86 type : A86 PARAPASS.ASM
;
; A86 can be obtained from: Eric Isaacson
; 416 E. University
; Bloomington, IN 47401
; (812)339-1811
;
;
; DESCRIPTION : This program allows the interactive specification of
; command line parameters. Microsoft EDLIN editor for
; instance requires that the file to be edited be specified
; on the command line (example: edlin myfile.doc). In a
; operating environment such as DESQview this may not be
; convenient however since parameters which are passed in
; environments such as DESQview are static (i.e. you must
; be content to edit myfile.doc constantly). This program
; was developed to get around that problem. When you run
; this program it will prompt you for the file to execute
; (which must have a fully qualified path name) and the
; parameters to pass to that program. It then runs the
; program and 'fools' the program into thinking the para-
; meters were passed on the command line.
;
;
; Miscellaneous Equates
;
space equ 20h ; space
cr equ 0dh ; carriage return
main: call init ; get switches etc. on command line
test b[status],80h ; is quiet bit set?
jnz >l1 ; yes
mov dx,begin_msg ; no, output program header
mov ah,9h
int 21h
l1: mov bx,[2ch] ; specify environment block address
mov [par_blk],bx ; pass the environment we got.
mov [p1],ds ; THIS IS KLUDGEY SO I WANT TO
mov [p2],ds ; DO THIS BETTER LATER
mov [p3],ds
again: mov ch,0 ; clear ch
mov cl,[80h] ; get length of command tail
mov al,[prg_add] ; see if we have a program name
cmp al,0
jne >l1 ; yes we do
getname: mov dx,name_msg ; nope, get program name
mov ah,9h ; this will send prompt even
int 21h ; if quiet bit is set.
mov b[80h],7fh ; allow 128 bytes length
mov dx,80h ; get program name
mov ah,0ah
int 21h
mov ah,[81h] ; get length of read
inc ah ; increase it by one
mov [80h],ah ; with this section we are
mov b[81h],space ; simulating, getting the program
; name on the command line
call init ; call init again
jmp again ; try it again
l1: call valid ; check validity of filename
cmp al,0eh ; invalid name? (0eh invalid
jne >l2 ; file name error code)
jmp alt ; yes, display error message
; use alternate entry point
l2: mov si,[prg_add] ; source pointer to name of program to run
and si,0ffh ; make sure msb is zero
mov di,prg_nam ; destination pointer
l3: mov al,[si] ; get a byte
mov [di],al ; put it in destination
inc si ; take care of pointers and such
inc di
loop l3 ; go get some more
mov b[si],' ' ; put ' : $' at end of command tail for later use
inc si ; so we can output to user
mov b[si],':'
inc si
mov b[si],'$'
test b[status],80h ; is quiet bit set?
jnz >l1 ; yes
mov dx,crlf ; output crlf
mov ah,9h
int 21h
mov dx,prompt ; prompt for parameters
mov ah,9h ; output it
int 21h
mov dl,[prg_add] ; output program name
mov dh,0
int 21h
mov dx,crlf ; output crlf
mov ah,9h
int 21h
l1: mov dx,cmd_line-1 ; get cmd_line
mov ah,0ah
int 21h
mov dx,crlf ; output crlf
mov ah,9h
int 21h
mov ah,29h ; put cmd_line in FCB #1
mov al,01 ; in case program looks there
mov si,offset cmd_line+1
mov di,ds
mov es,di
mov di,offset fcb1
int 21h
mov [stk_seg],ss ; save stack
mov [stk_off],sp
mov ah,25h ; intercept any <CNTRL> C
mov al,23h ; so we can ingore it
mov dx,int_ret
int 21h ; ds should already be correct
mov ah,4ah ; release memory for EXEC'd program
mov bx,eop-main ; eop-main = program length in bytes
shr bx,4 ; divide bx by 16 for paragraph length
add bx,11h ; add enough to take care of PSP
int 21h ; release memory
mov dx,prg_nam ; set up to EXEC program
mov bx,par_blk
mov al,0
mov ah,4bh
int 21h ; EXEC program
mov ss,[stk_seg] ; restore stack
mov sp,[stk_off]
jc alt ; if error print message
jmp good_exit ; if no error were done
int_ret: iret ; dummy interrupt handler
alt: mov bl,al ; convert error number to ASCII
cmp bl,0ah
jg >l1
add bl,30h ; convert to ASCII 1-9
mov [error],bl
jmp >l2
l1: add bl,37h ; convert to ASCII A-Z
mov [error],bl ; put error number in head_msg
l2: mov dx,head_msg ; output header
push ax ; save ax
mov ah,9h
int 21h
pop ax ; restore it
cmp al,1h ; oh no an error,find out which one
je err1 ; err1=function invalid
cmp al,2h
je err2 ; err2=file not found,path invalid
cmp al,5h
je err5 ; err5=access denied
cmp al,8h
je err8 ; err8=not enough memory
cmp al,0ah
je erra ; erra=environment invalid
cmp al,0bh
je errb ; errb=format invalid
cmp al,0eh ; erre=invalid filename
je erre ; LOCAL ERROR NOT SYSTEM
cmp al,0fh ; improper bundling of switches
je errf ; LOCAL ERROR NOT SYSTEM
mov dx,erru_msg ; unknown error OH MY!
mov ah,9h
int 21h
jmp bad_exit
err1: mov dx,err1_msg ; output the various error messages
mov ah,9h
int 21h
jmp bad_exit
err2: mov dx,err2_msg
mov ah,9h
int 21h
jmp bad_exit
err5: mov dx,err5_msg
mov ah,9h
int 21h
jmp bad_exit
err8: mov dx,err8_msg
mov ah,9h
int 21h
jmp bad_exit
erra: mov dx,erra_msg
mov ah,9h
int 21h
jmp bad_exit
errb: mov dx,errb_msg
mov ah,9h
int 21h
jmp bad_exit
erre: mov dx,invalid_msg
mov ah,9h
int 21h
jmp bad_exit
errf: mov dx,bundle_msg
mov ah,9h
int 21h
jmp bad_exit
bad_exit: mov ah,4ch ; al should have error code
int 21h
good_exit: mov al,0 ; quit with return code 0
mov ah,4ch
int 21h
init: mov bx,81h ; look for switches starting at
scan: mov al,[bx] ; PSP address 81h
cmp al,cr ; if cr were done
jne >l1
jmp pname ; done, so go look for program name
l1: cmp al,space ; if space skip it
je >l2
cmp al,'/' ; if not switch keep looking
jne >l2
inc bx ; it's a switch, which one?
mov al,[bx+1] ; before switch test make sure
cmp al,space ; next character is a space or /
; or cr else the switches are not
; bundled correctly
je >l3
cmp al,'/'
je >l3
cmp al,cr
je >l3
mov al,0fh ; internal error code
jmp alt ; jmp to alternate error entry point
l3: mov al,[bx] ; HERE WE TEST FOR ALL SWITCHES
cmp al,'q' ; quiet mode?
jne >l4
or b[status],80h ; set quiet bit
l4: cmp al,'Q'
jne >l2
or b[status],80h ; set quiet bit, END TEST FOR SWITCHES
l2: inc bx ; keep looking
jmp scan
pname: mov bx,80h ; now look for program name
mov cl,0h ; initialize length to zero
l1: inc bx
mov al,[bx]
cmp al,cr ; if cr we're done
je tini
cmp al,space ; if space skip it
je l1
cmp al,'/' ; a switch skip it plus next char
jne >l2
inc bx ; skip next char
jmp l1
l2: mov [prg_add],bl ; it's a prog name, bump count
l3: inc cl ; save location and look for cr
inc bx
mov al,[bx]
cmp al,cr
je tini
cmp al,space ; it a space, we assume program
jne l3 ; name is done
tini: mov [80h],cl ; save length of name
ret
valid: mov bl,[prg_add] ; start looking for .com or .exe
and bh,0 ; zero out bh
l1: mov al,[bx]
cmp al,cr ; found cr ?
je done ; yup
cmp al,'.' ; looking for '.'
je >l2
inc bx
jmp l1
l2: inc bx ; look at next char
mov al,[bx]
cmp al,'c'
je >l3
cmp al,'C'
je >l3
cmp al,'e'
je >l4
cmp al,'E'
je >l4
mov al,0eh ; not valid, return with error
ret
done: mov al,0eh ; didn't find .??? so invalid
ret
l3: inc bx ; found 'c' look for 'o'
mov al,[bx]
cmp al,'o'
je >l5
cmp al,'O'
je >l5
mov al,0eh
ret ; no 'o' bad filename
l5: inc bx
mov al,[bx]
cmp al,'m'
je >l1
cmp al,'M'
jne >l2
l1: mov al,0 ; valid filename try it
ret
l2: mov al,0eh ; bad file name
ret
l4: inc bx ; found 'e' look for 'x'
mov al,[bx]
cmp al,'x'
je >l5
cmp al,'X'
je >l5
mov al,0eh
ret ; no 'X' bad filename
l5: inc bx
mov al,[bx]
cmp al,'e'
je >l3
cmp al,'E'
jne l2
l3: mov al,0 ; valid filename try it
ret
;
; General Messages
;
prompt: db 'Enter parameters to pass to $'
crlf: db 0dh,0ah,'$'
name_msg: db 0dh,0ah,'Enter filespec of program to execute '
db '(COM or EXE extension required) :',0ah,0dh,'$'
begin_msg: db 0dh,0ah,'Parapass - the parameter '
db 'passing program - Version 0.0',0dh,0ah,'$'
;
; Error Messages
;
head_msg: db 0dh,0ah,'parapass : error '
error: db 0,' - $'
err1_msg: db 'Invalid function (notify author).',0dh,0ah,'$'
err2_msg: db 'File not found or path invalid.',0dh,0ah,'$'
err5_msg: db 'Access denied.',0dh,0ah,'$'
err8_msg: db 'Insufficient memory.',0dh,0ah,'$'
erra_msg: db 'Environment invalid (notify author).',0dh,0ah,'$'
errb_msg: db 'Format invalid (notify author).',0dh,0ah,'$'
erru_msg: db 'Unknown error (notify author).',0dh,0ah,'$'
invalid_msg: db 'Invalid program name, must be COM or EXE.'
db 0dh,0ah,' '
db 'See instructions for BAT file execution.'
db 0dh,0ah,'$'
bundle_msg: db 'Improper switch configuration.',0dh,0ah,'$'
;
; Data
;
prg_add: db 0 ; offset of program name within PSP
prg_nam: db 128 dup (0) ; prg_nam buffer
db 7fh ; max characters to read on cmd_line
cmd_line: db 128 dup (?) ; command line buffer
stk_seg: dw 0 ; original SS contents
stk_off: dw 0 ; original SP contents
status: db 0 ; status byte : bit 7 set = quiet mode
par_blk: dw 0 ; segment address of
; environment descriptor
dw offset cmd_line; address of command line
p1: dw 0 ; to be passed to program
dw offset fcb1 ; address of default FCB 1
p2: dw 0
dw offset fcb2 ; address of default FCB 2
p3: dw 0
fcb1: db 0 ; file control block #1
db 11 dup ('?')
db 25 dup (0)
fcb2: db 0 ; file control block #2
db 11 dup (' ')
db 25 dup (0)
eop: db 0 ; end of program place holder
; used for program size
; calculation