Thursday, June 11, 2009

How to include YASM in Visual Studio 2005

Playing with SIMD or assembly is very enjoyable thing, you will love coding here. But believe me actual fun starts when you use on NASM or YASM to write assembly rather than working with IA32 inline (__Asm{...}) assembly development coding method. YASM has included some more features than NASM but the real issue with NASM is the limited debugging formats. Debugger available in NASM are for 'stabs'and 'dwarf2' only. If you work on visual studio than NASM no use. NASM will assemble the code but you can not debug the code. So the best choice is YASM.


YASM can be downloaded from here. YASM supports various output format and supports debug formats 'stabs', 'dwarf2' and 'CodeView (cv)' check this. So it can be included in Visual Studio 2005 for assembly/SIMD code development.

So today we will discuss about how to include YASM assembler in visual studio 2005 project. We will go step by step for better understanding. So here we goes:

1) Download the latest YASM.exe, if donwloaded Yasm executable binary is not named as yasm.exe; we have to rename it yasm.exe.

2) Go to directory "Program Files\Microsoft Visual Studio 8\VC\bin" where all VC related binaries are kept already and put yasm.exe into it.

3) Now you need file named as 'yasm.rules'. To get this, download latest source code of YASM. Actually you can build yasm.exe with this source project also, but I am not concern with that today . Now locate folder "\Mkfiles\vc8" in yasm folder, you will find 'yasm.rules' file there.

4) To use custom build tool of visual studio 2005, copy 'yasm.rules' file to "Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults".

5) Now simply write your assembly in a file added to your project with file extension '.asm'

6) To assemble a file with Yasm, select the Property Page for the file and the select Yasm Assembler in the Tool dialog entry. Then add following line to 'Misc' section in 'command line' menu of property page :-

Debug mode : yasm -f win32 -g cv8 -o "$(IntDir)\$(InputName)".obj "$(InputPath)"
Release Mode : yasm -f win32 -o "$(IntDir)\$(InputName)".obj "$(InputPath)"

Press Apply and you are done. Now enjoy SIMD/assembly with YASM in Visual studio 2005.
I hope, you will find this article useful.

Useful links:

1) YASM in Wiki
2) YASM Home page
3) Latest version for download
4) YASM Documentation
5) YASM in VS 2005

1 comment: