Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS Commands in Assembly 1

Status
Not open for further replies.

spudnuts

Technical User
Sep 30, 2002
123
0
0
US
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.

Information Assurance,CCNP,CST
 
BTW,

I'm using A86.

Information Assurance,CCNP,CST
 
You would need to use Int 21h Function 4B00h (AX) to execute an external program, set DS:DX 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



Hope this helps.

[vampire][bat]
 
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.

Later.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top