Make your own free website on

Tutorial: Dev-C++ for mixed MASM32/GCC Development

This page provides instructions on how to configure and use Dev-C++, a programmer's IDE, to develop mixed C-Assembly programs using MASM32.  Both Dev-C++ and MASM32 can be obtain free of charge from


From the first site you can download a Dev-C++ distribution that contains a full distribution of Mingw/GCC. The following instructions are based on version Dev-C++ 5.0 beta 9.2 (  of such distribution. Version 9 of MASM32 was used.

DISCLAIMER: Although I have made my best effort to provide accurate information, the following information and code are provided without any warranty, implicit or explicit. You can use it free of charge at your own risk. 

1) Download the zip file containing the sample code from here, and decompress it in an appropriate folder. You will provide you with files main.c, asmcode.asm and masm.mak, which you can use as templates for your program.

2) Modify
    a) masm.mak to reflect the path to the masm32 libraries in your system;
    b) asmcode.asm to reflect the location of the masm32 include files.

3) Create a new Dev-Cpp Console C-project and store it in the folder used to decompress the sample code in step 1. Close the default "main.c" without saving it.

4) Add to your project the files main.c and asmcode.asm:

  1. right-click on your project,
  2. select "Add to project" ,
  3. choose "All files" in the bottom "File of Type" pull-down menu
  4. select the above files and click OK

5) From "Project/Project Options"

  1. Select Files, then "asmcode.asm"; check the "Include in linking" box.
  2. Select "Makefile", click on the folder icon (low on the right) , click on "make.mak", then on the "Open" button and "Add".
  3. On the "Compiler" section, press on "linker" and select "Yes" on the "Generate debugging information" option. This will allow for including the symbols that are needed to debug your program using the included debugger.
  4. Click on OK

6) Go to "Tools/Compiler Options/Compiler", check the "Add these commands to the linker command line" option on, and enter


in the corresponding bottom text box. Then press OK.

8) Invoke "Execute/Compile". The following compiler messages


    resolving _i_avg by linking to _i_avg@8

will appear in the compiler message area, indicating compilation without error. More details about the compilation/assembly process can be observed on the "Compile log"

9) Now you can single step through you program using this nice interface. To start,

  1. select "Debug" on the bottom part of the window.
  2. Click on "main.c" on the left side to open the file on the editor, and press on the first instruction at line 21 (the one that assigns a value to variable a). 
  3. Strike the "Run to Cursor" button in the bottom section.

10) Notice that

  1. Execution should stop at the selected line, which should be blue now.
  2. The left section of the window is on "Debug" mode
  3. Watch variables by right-clicking and selecting "Add watch" (also from the Debug menu)
  4. To "watch" CPU registers, enter them as variables with $ in front (i.e. enter $eax to view eax), or select "Debug/View CPU window" to see all registers.
  5. FPU registers can be "watched" by specifying them as $st0 to $st7
  6. You can select "Next step" to single-step over functions, and "Step Into" to enter a function or procedure and single-step through it.

11) Once you are happy with your program, you can re-compile a "distribution" version by re-building without the debugging option and with optimization to increase performance. Striping the executable will usually reduce its size significantly.

12) Finally, although the above steps use C and MASM32, it may be relatively straightforward to adapt this process to use other languages.

Some Useful Links:

Art of Assembly Language Programming and HLA by Randall Hyde
WinAsm Studio
An Introduction to Assembly Language Programming
32bit Assembly Quick Start using Visual Studio and MASM on Windows
8086/88 Device Specifications
Gnu C and MASM (for Win32 programming)
Pentium Assembly Code Using gcc
MinGW - Documentation
Function Calling Conventions
DJGPP documentation
NASM Manual - Mixing Assembly and C
Inline Assembly with DJGPP