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