Category : C Source Code
Archive   : ARGEX2.ZIP
Filename : ARGV.ASM

 
Output of file : ARGV.ASM contained in archive : ARGEX2.ZIP
NAME argv
PAGE 60,132
;
; Alternate startup code module for setting up argv[]
; This code mimics the Unix handling of wildcard file names
; as program arguments. They will be expanded into a list
; of matching file names, each in a separate argv[] string.
;
; The job of this function is to call a C function with
; required parameters. The C function does the necessary
; expansion.
;
; John Maline 6-21-87
; Turbo C 1.00
;
; Turbo C 1.5 compatibility
; - use _argv and _argc as identifiers (not __argv, __argc)
; John Maline 2-24-88
;
INCLUDE rules.asi

Header@

; Externals

ExtSym@ _argc, WORD, __CDECL__
dPtrExt@ _argv, __CDECL__
ExtSym@ _psp, WORD, __CDECL__
ExtSym@ _envseg, WORD, __CDECL__
ExtSym@ _envLng, WORD, __CDECL__
ExtSym@ _osmajor, BYTE, __CDECL__
ExtProc@ abort, __CDECL__
ExtProc@ _setargs, __CDECL__

CmdTailOfs equ 080h ; cmd tail offset in PSP

CSeg@

PubProc@ _setargv, __CDECL__
;
; Set up parameters to expansion function
;
mov bp,sp
;
; Pointer to argc
;
IF LDATA
push ds
ENDIF
mov ax,offset _argc@
push ax
;
; Pointer to argv pointer
;
IF LDATA
push ds
ENDIF
mov ax,offset _argv@
push ax
;
; Far pointer to command tail
;
mov ax,_psp@
push ax
mov ax,CmdTailOfs
push ax
;
; Far pointer to program name
; in DOS 3.x, prog name starts 2 bytes past end of environment
; in DOS 2.x, we don't get a prog name (give pointer to null string)
; we'll actually backup before the 2 junk bytes to the null
; that terminates the environment.
;
mov ax,_envseg@
push ax ;seg of prog name
mov ax,_envLng@ ;end of env
dec ax ;back up to terminating \0
cmp _osmajor@,3
jb Dos2
add ax,3 ;DOS 3, mov up to prog name
Dos2 label near
push ax ;offs of prog name (or \0)
;
; Command line expansion function
; stat = _setargs(progname,cmdtail,argv,argc)
; (non-zero return indicates error)
;
call _setargs@
mov sp,bp ;fix stack
or ax,ax
jz ArgvOK ;zero return value?
jmp abort@

ArgvOK label near
ret

EndProc@ _setargv, __CDECL__

CsegEnd@
END


  3 Responses to “Category : C Source Code
Archive   : ARGEX2.ZIP
Filename : ARGV.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/