CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Location
    Finally back in Alaska
    Posts
    141

    inline assembly and 64 bit usage

    Hello all,

    Im usually in the managed forum, but I am working on converting a library ove to native c++, and am having a hard time getting visual studio (2010 express) to use the 64 bit registers, I am running 64 bit win 7 with a 64 bit amd processor. While trying to figure it out I came across the following on the msdn site:


    "One of the constraints for the x64 compiler is to have no inline assembler support. This means that functions that cannot be written in C or C++ will either have to be written as subroutines or as intrinsic functions supported by the compiler."

    So, if I am reading that correctly, I wont be able to convert the 32 bit routines, which are inlined assembly, to 64 bit?

    2 questions then, what is an intrisinc function? I know it is a function built into the compiler itself, they almost look like assembly instructions of some sort, if that is what they are, what is the purpose of having them within the compiler itself instead of in a library?

    The other question is, when the article mentioned implementing the functions as subroutines, is it talking about having those functions in a seperate asm file? I was hoping to make it easy for me to call into the assembly routines by using inline, but it looks like the wont let it be that easy for me huh?

    Anyways, if youd like to see the rest of the article that quote above came from it is:
    http://msdn.microsoft.com/en-us/library/wbk4z78b.aspx

    Thanks in advance

  2. #2
    Join Date
    Aug 2008
    Posts
    902

    Re: inline assembly and 64 bit usage

    An intrinsic function would be strlen, for example. Instead of calling a function in the standard library, the compiler simply replaces the call to a function with highly optimised inline code.

    Your options are either to re-write the assembly code as C/C++, or assemble it separately and then link to it.

  3. #3
    Join Date
    May 2000
    Location
    Armenia
    Posts
    201

    Re: inline assembly and 64 bit usage

    So, if I am reading that correctly, I wont be able to convert the 32 bit routines, which are inlined assembly, to 64 bit?
    Inline assembler can not be used in C/C++ sources which are compiling to x64 target platform (_asm and __asm keywords are not supported on x64 architecture).

    Intrinsics are small low-level built-ins, which are converted to short, optimized sequence of assembly instructions (also some assembly instructions are available in C/C++ code via intrinsics).

    Low-level functionality that sometimes needed in C/C++ code can be done using intrinsics instead of inline assembly, allowing to compile the code to both x86 and x64 platforms. Unfortunately only minor part of assembly instructions are covered by intrinsics. If you need advanced usage of asm instructions you can use Microsoft Macro Assembler (MASM) supplied with Visual Studio to compile assembly source into the object file, then link it with the object files obtained from C/C++ compilation.

  4. #4
    Join Date
    Aug 2009
    Location
    Finally back in Alaska
    Posts
    141

    Re: inline assembly and 64 bit usage

    Ya, I started down that road once, but couldnt get c++ to even see it (not even in the object browser). I was using c++/cli at the time trying it, I had used radasm to actually build the assembler part of it, but I was doing something wrong, even after I finally managed to link it in, I couldnt see it, Guess Ill have to try out the assembly forum next.

    Thanks for the info

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured