Vous êtes sur la page 1sur 6

Setting up NASM on Visual Studio

1. Go to http://www.tortall.net/projects/yasm/wiki/Download and download

Win32 VS2010.zip for use with VS2010 on 32-bit systems or Win64 VS2010.zip for use with VS2010 on 64-bit systems. Make sure it is the most current version.
2. Extract the files to a directory of your choosing and place the extracted file

vsyasm.exe into the Visual Studio 2010 bin: C:\Program Files\Microsoft Visual Studio 10.0\VC\bin or for 64-bit systems: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin

*
3.

If you have many projects you would like to use VSYASM with, put vsyasm.xml, vsyasm.props and vsyasm.targets into MSBuild's build customization directory: C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations VSYASM will then always be available in the Build Customizations dialogue. Now you may skip steps 5 and 9.

(Skip this step if you have Visual Studio 2010.)

Go to http://www.tortall.net/svn/yasm/trunk/yasm/Mkfiles/vc9/yasm.rules and download yasm.rules Choose File Save As (or File Save Page As in Firefox) and Save to the directory: C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults as yasm.rules. Be sure to change the Save as type to All Files (*.*) so as not to save it as a .txt file.
4. Make a C++ project in Visual Studio 2010. Choose File New Project and

select Win32 Console Application. Give a project Name (eg. mp00), choose a save Location, and press OK.

In the appearing window, look under the Application Settings. Uncheck Precompiled header, check Empty project, and press Finish.

5. Place the other extracted files, vsyasm.xml, vsyasm.props and

vsyasm.targets, into the directory of the project.


6. Copy files first.asm, driver.c, asm_io.inc, asm_io.asm, and cdecl.h from

S:\Academic\CSSE\CS\Cs323\Nasm\SampleNASM into your project directory.


7. Right-click on Header Files in the Solution Explorer pane, select Add

Existing Item, and browse for cdecl.h. Right-click on Source Files, select Add Existing Item, and browse for first.asm, driver.c, asm_io.inc, and asm_io.asm. Do NOT change lines 60 and 61 of first.asm to reference asm_main instead of _asm_main. The underscore is needed for compilation.

8. Right-click on the project name in the Solution Explorer and select Build

Customizations.
9. If vsyasm(.targets, .props) is not listed, click Find Existing and browse

for your projects directory and select vsyasm.targets, press OK and then No to the window that pops up.
10. Check the checkbox in the Build Customizations window next to

vsyasm(.targets, .props) and press OK.


11. Right-click on first.asm and select Properties. In the Item Type field, click the

arrow next to Does not participate in build, scroll down to and select Yasm Assembler, and press OK. Do the same for asm_io.asm.

12. Right-click on the project in the Solution Explorer and select Properties.

Expand Configuration Properties if it is not already expanded, then expand Yasm Assembler. Under the General option, change Debug Information from No to Yes( -g cv8 ), edit the Object File Name from $(IntDir) to $ (IntDir)%(Filename).obj, and press OK.

13. To ensure everything is working properly, select Build Build Solution from

the menu bar. If you get a build error that says error MSB3721: The command ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\"vsyasm.exe -Xvc -f Win32 -g cv8 -o "Debug\asm_io.obj" -rnasm -pnasm asm_io.asm" exited with code 1. C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vsyasm.targets 45 6 mp00 proceed to the bin folder for Visual Studio at C:\Program Files\Microsoft Visual Studio 10.0\VC\bin and edit the vsyasm.props file. Look on line 13 and change \Program Files (x86)\ to \Program Files\ then go back and rebuild your project.
14. To view the Registers Window for assistance with debugging, set a

breakpoint in driver.c at line 6. Click Debug on the menu, and select Start Debugging. To view the Registers Window, click Debug on the menu again, then navigate to Windows Registers.

You can also display the flags by right-clicking on the Registers Window and selecting Flags.

The Watches menu is generally useful, but may not work properly with NASM.

C files and ASM files cannot share the same file name. When both file types are compiled, they become OBJ files, which causes errors because of their same file name. Functions in ASM files will need an underscore preceding their names in both the global section and where they are coded. These underscores must be removed when switching back to IO. For more information for setup with Visual Studio 2005/2008 visit: http://www.tortall.net/projects/yasm/wiki/VisualStudio2005

Vous aimerez peut-être aussi