This guide is for how to facilate the compiling and running of your x86 program as it can get quite tedious to do it manually. I will use BAT script to automate the process.
Before doing this part I assume that you read the linking multiple files guide. As what we will do now is just automate a part of it.
- Clean all the .EXE .MAP .OBJ files in the current directory
- Compile all the .ASM files in the current directory
- Link ONLY FILES that you specify in the script. (This is the limitation of the script).
- Run the .EXE file
- Clean after the program is done running.
- Open your root code folder in VSCODE (The folder that contains all your .ASM files)
- Copy the run.bat file into the root code folder.
- Make sure that in your vscode settings the dosbox copies the whole workspace folder. (If not sure about this check the linking multiple files guide)
- Right Click and
open in emulator
- type
run
in dosbox and press enter. - And voila! Your program is running.
You have to edit the script just because you cant do this
TLINK *.OBJ
You have to specify the files that you want to link. This is because the TLINK command does not support wildcards. (If you know how to do this please tell me)
You can try to run this demo if you want make sure to cd
to the directory where the .asm and .bat files are located.
:: =========================================================
:: Author: Amir Anwar
:: This is a batch file to compile and run x86 assembly code
:: =========================================================
:: Clean files
echo "=================================="
echo "Clean files"
DEL *.MAP
DEL *.OBJ
DEL *.EXE
:: Compile
echo "=================================="
echo "Compile"
TASM *.ASM
:: LINKING (IMPORTANT)
echo "=================================="
echo "Linking"
TLINK MAIN.OBJ STRPROC.OBJ
:: YOU HAVE TO SPECIFY THE FILES MANULAAY TILL NOW
:: YOU CAN'T SAY TLINK *.OBJ
:: IF YOU FOUND ANOTHER WAY LET US KNOW
:: Run
MAIN.EXE
:: Clean files Silently you can remove this part
:: completely if you want it is not required
DEL *.MAP
DEL *.OBJ
DEL *.EXE