Here is my test.asm code. Basically 'nothing' inside because just want to get it to build and run without errors first.
.model small
.stack 64
.data
.code
main proc
mov ax,@data
mov ds,ax
mov ax,4c00h
int 21h
main endp
end main
I have tried using visual studio 2013 include the lib, add the linkers and all those guides from websites but no luck. Always getting this error message "error A2006: undefined symbol : DGROUP" for both MASM32 and visual studio 2013.
Please guide me step by step on the build and run.. Also, i tried using dosbox and this is as far i can go.. Keep having the illegal command. What am I doing wrong? :(
How to build a MSDOS program with MASM32 and run it in DOSBox
Download MASM32 and DOSBox for Windows and install them. MASM32 should be afterwards in C:\masm32 and DOSBox in %ProgramFiles^(x86)%\DOSBox-0.74 resp. %ProgramFiles%\DOSBox-0.74.
Start the MASM Quick Editor (
qeditor.exe
) and loadmenus.ini
.Scroll down to
Insert five lines:
Eventually you have to change
%ProgramFiles(x86)%
to%ProgramFiles%
- where DOSBox had been installed. Type in a command promptSET
and look which directories are allocated to that environment variables. Save the file and restart the MASM32 Quick Editor. Now you have under "Project" three new items at the end.Type in a MS-DOS assembly program in MASM syntax:
and save it under an 8.3 name e.g.
hello.asm
.Click on Project/Build 16-bit .asm to .exe and close the window by pressing any key. Now click on Project/Run in DosBox. The DOSBox windows will open and the program will run. The DOSBox windows stay open, so you start the program then at the command prompt there, e.g. type in "hello.exe".
VS doesn't include a 16-bit tool set. The most common 16-bit Microsoft assembler / tool set is MASM (
ML.EXE
) 6.11. (There's a patch to update it to 6.14, but then you need a dos extender or you need to run it from a 32-bit dos console window). There may be other 16-bit versions of MASM apparently available for download. Hopefully these will include instructions for how to install and setup the environment variables.There are other programs that go along with Microsoft's 16 bit tool set, a linker, codeview (source level debugger), nmake (make utility), h2inc (converts a c .h file into an assembler .inc file), qh (quick help), pwb (programmer's work bench, a text base integrated development environment), and 16 bit versions of C / C++.
DGROUP normally groups
_data
,_bss
, andstack
into a single segment, but if you're using.model
, you shouldn't need to reference it, and the names are different, like@data
instead of_data
. Example .asm file (the,c
means that C calling convention is used).To paraphrase: how do I inflate a bicycle tire with a potato?
Your assembly is 16-bit, and you're targeting MS-DOS (the
int21
call is a giveaway). Neither VS2013 nor MASM32 is capable of generating DOS executables. Try a different assembler, i. e. NASM. Alternatively, read up on modern assembly.