Search code examples
assemblydosx86-16emu8086

Assembler can't open file


After assembling the MINI-44.asm, I tried to run MINI-44.com_. Then it showed "unable to open file". Then I copied all the files in MyBuild to MySource and vdrive\c for just in case. But either it's not locating any files or unable to open files. How do I fix this?

;#MAKE_EXE#
.model small
.code
FNAME equ 9EH
ORG 100H
START:
MOV AH,4EH;
MOV DX,OFFSET COM_FILE;
INT 21H;
SEARCH_LOOP:
JC DONE;
MOV AX,3D01H;
MOV DX,FNAME; 
INT 21H;
XCHG AX,BX;
MOV AH,40H;
MOV CL,42H;
MOV DX,100H;
INT 21H;
MOV AH,3EH;
INT 21H;
MOV AH,4FH;
INT 21H;
JMP SEARCH_LOOP;
DONE:
RET;
;COM_FILE DB 'C:\EMU8086\vdrive\C\*.com_',0;
;COM_FILE DB 'C:\EMU8086\MyBuild\*.com_',0;
COM_FILE DB '\MySource\*.com',0;
;COM_FILE DB '\vdrive\C\*.com_',0;
;COM_FILE DB '\MySource\*.com_',0;
;COM_FILE DB 'C:\EMU8086\MySource\*.com_',0;
END START;

Solution

  • In addition to the things already mentioned in Michael Petch's and Peter Cordes' comments:

    You should not use a fixed address (9Eh) but a label for the file name.

    If you modify the code, the address is no longer correct. Using a label will fix this.

    And 9Eh cannot be the correct address because a .com file starts at address 100h, so all addresses inside the .com file must be at least 100h.

    It is not sure what is located at address 9Eh (it is an address inside the address space reserved for the command line; however, this address is not used if the command line arguments are less than ~20 bytes long). However, obviously the data stored at 9Eh is not a file name!

    So it is clear that you'll get a "file not found" error because the dx register contains 9Eh but there is no valid file name at address 9Eh.