none
'__asm' keyword not supported on this architecture RRS feed

  • Question

  • Hi All,

    I am building the 64-bit application using 32-bit application
    I have selected X64 in Active platform and it has defined _M_AMD64 platform.
    When I try to compile my below code

    #if _AMD64_

    __inline long xyz_setbit32(volatile long *p,int b) {

    unsigned char c;

    __asm {

    mov eax,b

    mov ebx,p

    lock bts [ebx],eax

    setc c

    }

     

    return (int)c;

     

    #endif

    I get below error

     '__asm' keyword not supported on this architecture

    I know that  _asm is not supported in x64, how can i convert this code to x64 compatible.

    Please provide me the complete steps to how to convert the above code.

    Thanks,
    Prash

    }

    Tuesday, October 27, 2009 7:30 AM

Answers

  • A think that the function or its body can be replaced by InterlockedBitTestAndSet or _interlockedbittestandset.

    • Marked as answer by Nancy Shao Monday, November 2, 2009 1:45 AM
    Tuesday, October 27, 2009 7:52 AM
  • Hi Jonjang,

     

    As you know, Inline ASM is not supported for x64. But you can use MASM or compiler intrinsic. There are two workarounds which are separate assembly with MSASM ( which supports x64 fully) and compiler intrinsic: ml64-Specific Directives and 32-Bit Address Mode(Address Size Override). For more information, please see:

     

    MASM for x64 (ml64.exe) 

     

    And there is a thread as same issue as yours, please see:  asm in VS2005 for x64

     

    Best Regards,

    Nancy

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Monday, November 2, 2009 1:46 AM
    Thursday, October 29, 2009 8:30 AM

All replies

  • A think that the function or its body can be replaced by InterlockedBitTestAndSet or _interlockedbittestandset.

    • Marked as answer by Nancy Shao Monday, November 2, 2009 1:45 AM
    Tuesday, October 27, 2009 7:52 AM
  • Hi Jonjang,

     

    As you know, Inline ASM is not supported for x64. But you can use MASM or compiler intrinsic. There are two workarounds which are separate assembly with MSASM ( which supports x64 fully) and compiler intrinsic: ml64-Specific Directives and 32-Bit Address Mode(Address Size Override). For more information, please see:

     

    MASM for x64 (ml64.exe) 

     

    And there is a thread as same issue as yours, please see:  asm in VS2005 for x64

     

    Best Regards,

    Nancy

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Monday, November 2, 2009 1:46 AM
    Thursday, October 29, 2009 8:30 AM
  • Hi

    Thanks for you reply.

    Could please convert my above sample into MASM and compliler intrinsic.

    Please give me the link where i can search for sample examples.



    Thanks,
    Prash
    Friday, October 30, 2009 11:27 AM
  • Hi jonjang,

    Viorel gave you the correct compiler intrinsic. It is documented here:

    _interlockedbittestandset, _interlockedbittestandset64

    Best Wishes,
    -David Delaune
    Friday, October 30, 2009 11:32 AM
  • Hi David

    Thanks for your reply.

    I goge through compiler intrensics but i dint not understand how to replace with my below code

    #if _AMD64_

    __inline long xyz_setbit32(volatile long *p,int b) {

    unsigned char c;

    __asm {

    mov eax,b

    mov ebx,p

    lock bts [ebx],eax

    setc c

    }

    return (int)c;

    Could you please convert above sample code using compiler intrensic
    _interlockedbittestandset, _interlockedbittestandset64

    Thanks,
    Prash

    Wednesday, November 11, 2009 5:31 AM
  • Call _interlockedbittestandset instead of your xyz_setbit32 function. I.e., change the code calling xyz_setbit32, not xyz_setbit32 itself (unless you want to make xyz_setbit32 a wrapper for _interlockedbittestandset).
    Wednesday, November 11, 2009 5:38 AM