Image Map Image Map
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: DOS Disk file access help.

  1. #11

    Default

    Yes, if you want to run your program as "PROG myfile.dat".
    It might be good to forcefully terminate the command line after the filename by setting the byte at PSP+81h+11d to zero.

    I don't know if you need to care about leading or trailing whitespace.

  2. #12
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    4,306
    Blog Entries
    1

    Default

    I think processing through the entire command line is prudent. Leading spaces causing the program to fail are embarrassing. Also makes it easier to add support for switches or multiple files.

  3. #13
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    31,810
    Blog Entries
    18

    Default

    Quote Originally Posted by Hugo Holden View Post
    Chuck, does that mean I can use the PSP +81h as the effective address for the filename prior to the start of the code listed in post #4 ? or would it require more steps ?
    Sure, if it's convenient. On the Unix-style DOS I/O, PSP+80h has no particular use other than passing the command arguments.
    After MS stated that it was going to drop FCB support, I recoded 22Nice to simulate the FCB operations, but the I/O is all done Unix-style. It has advantages--you can include subdirectories in the file name name; e.g. C:\ONE\TWO\THREE\MYFILE

  4. #14

    Default

    Quote Originally Posted by Chuck(G) View Post
    Sure, if it's convenient. On the Unix-style DOS I/O, PSP+80h has no particular use other than passing the command arguments.
    After MS stated that it was going to drop FCB support, I recoded 22Nice to simulate the FCB operations, but the I/O is all done Unix-style. It has advantages--you can include subdirectories in the file name name; e.g. C:\ONE\TWO\THREE\MYFILE
    Can you suggest the lines of code you would use (which will help me to avoid any errors initially getting the filename effective address into dx)

  5. #15
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    31,810
    Blog Entries
    18

    Default

    You want code to save the filename elsewhere (not 80h?). If so, how about this chestnut that I wrote back in the 1980s for a .exe file (cs ≠ ds):

    Code:
    ;  On entry, DS->PSP segment.
    ve:                                     
    	mov	ax,seg dgroup
    	mov	es,ax
      	mov	si,0080h	; unformatted parameter area
    	cld
    	lodsb			; get count
    	cbw
    	mov	cx,ax		; save count of characters
    ve2:
    	test	cx,cx
    	jnz	ve3		        ; if more data
    	jmp	verr2		; if no parameter, call it error
    
    ve3:
    	lodsb
    	dec	cx
    	cmp	al,' '
    	je	ve2		; loop until parameter hit
    	lea	di,iname ; set name
            mov  dx,di
    	cld
    	rep movsb	; move the name
    And you've got your filename pointed to by DS;DX. "iname" is a location that you've provided for the storage of the name. This can be convenient--the code that follows this creates files with the same base name, but different extensions.

    After that, (iname) has your file name. This was coded with a very old version of MASM, maybe 2.0, hence the "lea" instead of "mov offset". In fact, for that version of MASM, lea's were gratuitously converted to mov instructions where possible. If you're writing for a .COM file, just substitute "mov ax,cs" for "mov ax,seg dgroup"

  6. #16

    Default

    Quote Originally Posted by Chuck(G) View Post
    You want code to save the filename elsewhere (not 80h?). If so, how about this chestnut that I wrote back in the 1980s for a .exe file (cs ≠ ds):

    Code:
    ;  On entry, DS->PSP segment.
    ve:                                     
    	mov	ax,seg dgroup
    	mov	es,ax
      	mov	si,0080h	; unformatted parameter area
    	cld
    	lodsb			; get count
    	cbw
    	mov	cx,ax		; save count of characters
    ve2:
    	test	cx,cx
    	jnz	ve3		        ; if more data
    	jmp	verr2		; if no parameter, call it error
    
    ve3:
    	lodsb
    	dec	cx
    	cmp	al,' '
    	je	ve2		; loop until parameter hit
    	lea	di,iname ; set name
            mov  dx,di
    	cld
    	rep movsb	; move the name
    And you've got your filename pointed to by DS;DX. "iname" is a location that you've provided for the storage of the name. This can be convenient--the code that follows this creates files with the same base name, but different extensions.

    After that, (iname) has your file name. This was coded with a very old version of MASM, maybe 2.0, hence the "lea" instead of "mov offset". In fact, for that version of MASM, lea's were gratuitously converted to mov instructions where possible. If you're writing for a .COM file, just substitute "mov ax,cs" for "mov ax,seg dgroup"
    Thanks, I will try this combined with the code from post #4 and assuming I don't foul up the instructions to the assembler, it should work.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •