Simple question, how do I execute a dos command (i.e. COPY, XCOPY, DIR, DEL, etc) in assembly. I have a good grip on using DOS interupts but lost on how to call and execute a dos command within an assemply program.
You would need to use Int 21h Function 4B00h (AX) to execute an external program, set DSX and ES:BX as appropriate.
XCOPY.EXE is independent program, whereas COPY, DIR and DEL are internal commands. To run these pass CMD.EXE as the program and the relevant command as the command tail.
For DIR C:\ you would use CMD.EXE (don't forget to include the full path) and /C DIR C:\ as the command tail. The /C switch tells CMD.EXE to execute the following command and then terminate.
An undocumented DOS Interrupt - as least as far as DOS 6, INT 2Eh takes a standard COMMAND.COM command line in DS:SI and runs the command. This may or may not work in a windows DOS box - it didn't always work under DOS and may not be compatible with CMD.EXE
You probably will also have to release some memory that your program does not require for the int 21 / 4B00 function to work. Look on the web for Ralf Brown's interupt list for more info.
Another way to do DOS commands would be to use a couple of batch files. Write the commands you want the PC to do into one file -say JOBS.BAT. Have the main bat file do something like this:
LABEL: asmprogram.exe
call JOBS
goto LABEL
This assumes that your asm program can save enough state info to be restarted and know what it needs to do next.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.