Today, while helping others to solve the unavailability of DOSBox, I found several ways to compile and run assembly language, hereby record
DOSBox
Install DOSBox (this installation step will not be explained, Baidu has more)
Create a new folder anywhere, the name should not be too long, for example, mine is AsmTools
MASM.EXE, LINK.EXE, MASM.EXE that will be downloaded (these files can be 王爽老师的汇编语言论坛
found in)
In DOSBox 0.74 Opthions.bat
this last document plus
MOUNT C "D:\AsmTools" (引号内的是刚才创建的文件夹)
C:
So when you open DOSBox, it will be automatically loaded to the virtual c drive
Then enter debug to use debug
Put your compiled assembly language file (suffix .asm, suppose it is test.asm) in the folder you just created, and then perform the following steps in DOSBox
first step
masm test.asm
After completing this step, you will get a file with the suffix obj
Second step
link test.obj
After completing this step, you will get a file with the suffix exe
third step
test
This step is to execute the executable file
All operations are done here
MASM32+DOSBox
The student who asked me for help was unable to use the previous method, so I found another method, as follows:
Download MASM32 on the official website (not detailed in this step)
Perform the following operations in the environment variable (if you don't have this entry, you can create it):
include项中添加C:\masm32\include
lib中添加C:\masm32\lib
path中添加C:\masm32\bin
Then open the installation directory of MASM32, search for link in it, and perform the following operations:
将masm32安装文件夹的bin目录下的link.exe改为link32.exe,同时link16.exe改为link.exe
(其实对与原来的link.exe向怎么操作都可以,因为我们其实用不到它)
Then open cmd, enter the directory where you wrote the assembly language program (assuming test.asm has been written in it), and proceed as follows:
first step
ml /c test.asm
After completing this step, you will get a file with the suffix obj
Second step
link test.obj
After completing this step, you will get a file with the suffix exe
Then open DOSBox (its configuration is the same as the previous method), and proceed as follows
test
(In fact, just run the executable file, it can't be run directly in win10)
At this point this method finally succeeded
But these two methods are very troublesome, especially the second one, so I found emu8086
emu8086
https://emu8086-microprocessor-emulator.en.softonic.com/
The above one is the download address of emu8086's official website, just download and install it
use:
- New Construction
The first time you go in, it should allow you to create a new project. This is to click on empty workspace, not the first time to go in. Just click on new in the upper left corner (you must have used other compilers, they are almost the same)
- Write code
There is nothing to say in this step, here is a code for everyone to test (written for entry, forgive me for the big guys)
STACKS SEGMENT STACK
STACKS ENDS
DATAS SEGMENT
string DB 'hello world', 0dh, 0ah, '$'
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START: MOV AX,DATAS
MOV DS,AX
MOV DX, offset string
MOV AH, 9
INT 21H
MOV AX,4C00H
INT 21H
CODES ENDS
END START
- Save code
Click save in the menu bar, and then. . .
- Compile
Click compile in the menu bar
If your code is okay, run is in the green activated state, click to proceed to the next step, if it is not in the activated state, change the code
- run
Click run
- Single step execution: F8