64-bit registers not recognized by the compiler?

64-bit registers not recognized by the compiler?

I have made a simple test program to try out inline assembly, as follows:

#include <stdio.h>

int main()
	{
		int a=0;

		__asm {
				mov eax, 1
				mov [a], eax
		}
		
		printf("%d", a);

		return 0;
	}

It builds and outputs 1 before exiting as it should. However, if I change "eax" to "rax" to access the full 64-bit register, building the program fails with the following error message from the compiler:

1>------ Build started: Project: test4, Configuration: Debug Win32 ------
1>Build started 2014-06-06 17:39:44.
1>InitializeBuildStatus:
1>  Creating "Debug\test4.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>MessageBuildingWithCompiler:
1>  Building with Intel(R) C++ Compiler XE 14.0
1>ClCompile:
1>  ***** ClCompile (Win32 - Intel C++)
1>  test4.cpp
1>test4.cpp(8): error : label "rax" was referenced but not defined
1>    				mov rax, 1
1>    				    ^
1>  
1>  compilation aborted for test4.cpp (code 2)
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.10
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I am using Intel Composer XE 2013 SP1 Update 3 integrated into Visual Studio 2010. All compiler settings for this test project are at default. Anyone have any ideas what might be going on here? Could it be the Win32 part that should somehow be changed before 64-bits registers will be available?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

Use the configuration manager to add an x64 configuration. On (about) the 2nd line of the VS GUI is a pull-down window with "Win32" listed. Click on the pull-down arrow. If you do not see x64, click on Configuration Manger, then Add, and select x64.

Win32 is IA32 (32-bit), x64 is Intel64 (64-bit).

Jim Dempsey

Thanks! That did the trick.

take into account that using this configuration you are getting 64-bit binary that will work on 64 bit versions of windows.

--Vladimir

Leave a Comment

Please sign in to add a comment. Not a member? Join today