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

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,307
    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,813
    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,813
    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.

  7. #17

    Default

    I'm still having difficulties getting a floppy disk file to open from the command tail and trying a number of methods. The code attached uses a method from Joerg Mayer's Assembly book, hybridized with the code suggested in post #4. It uses org 80h and the locations which follow to help create the effective address for the filename to load dx. This is the part where its coming unstuck somehow. This program assembles and links normally to make the .exe (except for the no stack error), but it fails to open the disk file and reports that error right away. Any suggestions as to what I have done wrong ?
    Attached Images Attached Images

  8. #18

    Default

    ...oops I have just seen that I missed a JMP close line of code before the error messages, that might be all it was, I will retest it now !

    ..it still returns the cannot open file message, and a few symbols before that on the row above, which are not part of the message and I'm not sure of the significance of them.

    I also double checked, its not moving the data to memory, so its not an error message issue, its not opening the file.
    Attached Images Attached Images
    Last edited by Hugo Holden; Today at 06:59 PM.

  9. #19
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    31,813
    Blog Entries
    18

    Default

    How about posting the relevant snippet of code? It shouldn't be that difficult.

  10. #20

    Default

    Quote Originally Posted by Chuck(G) View Post
    How about posting the relevant snippet of code? It shouldn't be that difficult.
    I have, its the jpeg image on post #17

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
  •