For many years I’ve been working with Visual Studio as my main development IDE. I’ve seen many incarnations, since Visual C++ 2.0, through VC++ 2.1, 2.2, 4.0-4.2 and from there also Visual Basic 5.0, 6.0, and Visual Studio.NET, 2003, Visual Studio 2005, 2008 and now Visual Studio 2010 with “Dev11” gleaning at the horizon. Knowing your development thoroughly is a great advantage. I ‘d rather not go back to other editors and/or environments.
That’s why I have created a Makefile project for Visual C++ and hooked up the AS09 compiler for 6809 code.
Preparing the project
You will need to download Visual C++ 2010 Express to do this. If you’re spoiled like me, you might just have a paid version of Visual Studio 2010, which should include Visual C++.

After choosing the Makefile project you can choose a filename for your project. I have named it HelloWorld

A wizard will start that allows you to enter lots of information. Simply press Finish, as you can set this up in another dialog (with some more space for editing).
At the Solution Explorer, you will see the new HelloWorld project. Right-click it and choose Properties.

Go to the Configuration Properties, NMake at the left tree and fill the three command-lines with the following:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" /f hello.mak BUILD=Debug all
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" /f hello.mak BUILD=Debug all
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\nmake.exe" /f hello.mak BUILD=Debug clean
This means that we will have a hello.mak NMAKE file for our compiler to use. There will be two configurations for building, rebuilding (the same for now) and cleaning.
Set the Output to hello.bin. That is the name of the file that we will be producing.
Add a new text file “hello.mak” to the project. You will also need to include the hello.asm file in the root of the project. The result looks like this:

Editing the make file
Open the hello.mak file and copy the following text in it:
.SOURCE :
.SUFFIXES : .asm .bin
AS="C:\Program Files (x86)\AS09\AS09.exe"
ASFLAGS=-cgiv -h0
target = hello.bin
objects = hello.bin
.asm.bin:
$(AS) $(ASFLAGS) -l$(BUILD)\$*.lst -o$(BUILD)\$@ $<
all: $(objects)
clean:
del $(BUILD)\*.lst
del $(BUILD)\*.dbg
del $(BUILD)\$(target)
Explaining the contents of the make file
Let’s take a short look at the individual elements.
.SOURCE is not used, but indicates subdirectories where source code might be located. .SUFFIXES lists the extensions of files that while be recognized.
AS is a shorthand macro for the compiler and the ASFLAGS for the compiler flags.
The -cgiv flags means that the compiler will:
- output cycles counts per instruction (c flag, which is relevant in combination with the l flag)
- generate debug information (in a separate .dbg file)
- be case-insensitive
- be verbose in its output
The flag –h0 indicates infinite page length for the generated listing file hello.lst.
Next are the target and objects, which indicate the thing we will produce (target) and which things (objects) are needed to create the target. In this simple case this is the same. More complex scenarios might have other objects accumulating into the target.
The line .asm.bin: and the line after that is a inference rule that tells NMake how to create a .bin file from a .asm file. In this case it is accomplished by:
- $(AS) construct the compiler command
- $(ASFLAGS) adds the flags to the command
- with a listing flag –l at the location $(BUILD)\$*.lst
The last part will expand to something like DEBUG\hello.lst, because the macro BUILD holds the current build configuration (DEBUG or RELEASE) and $* is the current file (from the rule) without an extension (so hello.asm becomes simple).
- at the output $(BUILD)\$@ as specified by the –o flag
This will expand to DEBUG\hello.bin, because $@ is the target of the rule (in this case the .bin that needs to be created)
- with input file $< that holds the complete filename that is the lefthand side of the rule (hello.asm)
The final sections indicate the all and clean configurations. All is the build configuration that is used for both a normal Build and the Build All. Since we have only one project the two use the same “all” configuration. It will build all objects are indicated by the objects= line. The clean configuration will run three delete commands that get rid of all .lst, .dbg files and the target.
Building the solution
You can now build the project from the Build menu, Build Solution (shortcut is Ctrl+Shift+B). The makefile project will run the NMake utility and feed it the hello.mak file. plus the value “all” to build. The result should be something like this in the Output window:
1> Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> "C:\Program Files (x86)\AS09\AS09.exe" -cgiv -h0 -lDebug\hello.lst -oDebug\hello.bin hello.asm
1> AS09 Assembler for M6809 [1.42]. Copyright 1994-2007, Frank A. Kingswood
1>
1> Optimization enabled.
1> Pass 1.
1> 20 lines read, no errors in pass 1.
1> Pass 2.
1> No errors in pass 2.
1> Checking binary file boundaries.
1> Writing binary file "Debug\hello.bin".
1> Wrote binary from address $0000 through $0022.
1> Total size 35 bytes.
1>
1> Reading from file "hello.asm"
1>
1> Reading from file "hello.asm"
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Clicking the Show All Files button at the top of the Solution Explorer reveals the contents of the Debug folder:

where all output is located. Running Clean solution from the Build menu will get rid of the output of the build proces.
More information can be found at the MSDN website.
Posted
02-23-2012 7:10
by
Alex Thissen