1 2Building YASM with Microsoft Visual Studio 2008 (C/C++ v9) 3---------------------------------------------------------- 4 5This note describes how to build YASM using Microsoft Visual 6Studio 2008 (C/C++ v9). It also provides a way of using 7these files to build YASM with Visual Studio 2005 (C/C++ v8). 8 91. The Compiler 10--------------- 11 12If you want to build the 64-bit version of YASM you will need 13to install the Visual Studio 2008 64-bit tools, which may not 14be installed by default. 15 162. YASM Download 17---------------- 18 19First YASM needs to be downloaded and the files placed within 20a suitable directory, which will be called <yasm> here but can 21be named and located as you wish. 22 233. Building YASM with Microsoft VC9 24----------------------------------- 25 26Now locate and double click on the yasm.sln solution file in 27the 'Mkfiles/vc9' subdirectory to open the build project in 28the Visual Studio 2008 IDE and then select: 29 30 win32 or x64 build 31 release or debug build 32 33as appropriate to build the YASM binaries that you need. 34 354. Using YASM with Visual Sudio 2008 and VC++ version 9 36------------------------------------------------------- 37 381. Firstly you need to locate the directory (or directories) 39where the VC++ compiler binaries are located and put copies 40of the appropriate yasm.exe binary in these directories. A 41typical location is: 42 43C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin 44 45Depending on your system you can use either the win32 or the 46x64 version of YASM. 47 482. To use the new custom tools facility in Visual Studio 2008, 49you need to place a copy of the yasm.rules file in the Visual 50Studio 2008 VC project defaults directory, which is typically 51located at: 52 53C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC 54 \VCProjectDefaults 55 56This allows you to configure YASM as an assembler within the VC++ 57IDE. To use YASM in a project, right click on the project in the 58Solution Explorer and select 'Custom Build Rules..'. This will 59give you a dialog box that allows you to select YASM as an 60assembler (note that your assembler files need to have the 61extension '.asm'). 62 63To assemble a file with YASM, select the Property Page for the 64file and the select 'Yasm Assembler' in the Tool dialog entry. 65Then click 'Apply' and an additional property page entry will 66appear and enable YASM settings to be established. 67 68As alternative to placing the yasm.rules files as described 69above is to set the rules file path in the Visual Studio 2008 70settings dialogue. 71 725. A Linker Issue 73----------------- 74 75There appears to be a linker bug in the VC++ v9 linker that 76prevents symbols with absolute addresses being linked in DLL 77builds. This means, for example, that LEA instructions of 78the general form: 79 80 lea, rax,[rax+symbol] 81 82cannot be used for DLL builds. The following general form 83has to be used instead: 84 85 lea rcx,[symbol wrt rip] 86 lea rax,[rax+rcx] 87 88This limitation may also cause problems with other instruction 89that use absolute addresses. 90 916. Building with Visual Studio 2005 92----------------------------------- 93 94The Python program vc98_swap.py will convert VC9 build projects 95into those needed for Visual Studio 2005 (VC8). It will also 96convert files that have been converted in this way back into their 97original form. It does this conversion by looking for *.vcproj 98and *.sln files in the current working directory and its sub-directories and changing the following line in each *.vcproj 99file: 100 101 Version="9.00" 102 103to: 104 105 Version="8.00" 106 107or vice versa. 108 109The lines 110 111 Microsoft Visual Studio Solution File, Format Version 10.00 112 # Visual Studio 2008 113 114in *.sln files are changed to: 115 116 Microsoft Visual Studio Solution File, Format Version 9.00 117 # Visual Studio 2005 118 119or vice versa. 120 121Because it acts recursively on all sub-directories of this 122directory it is important not to run it at a directory level 123in which not all projects are to be converted. 124 1257. Acknowledgements 126------------------- 127 128I am most grateful for the fantastic support that Peter Johnson, 129YASM's creator, has given me in tracking down issues in using 130YASM for the production of Windows x64 code. 131 132 Brian Gladman, 10th October 2008 133