6

Visual Studio 用に指定された、C++ ソースで次の ASM インライン コードを使用しようとしています。

__asm {
mov ecx,target
}

target は void* ポインターです。これを GCC 互換コードに変換する方法がわかりません。私はGCCがシンタックスを次のように使用することを知っています:

asm (".intel_syntax noprefix");    
asm ("mov ecx,target");    

しかし、明らかにこの状況では変数に問題があります。では、GCC for Windows を使用してインライン ASM でポインターを使用する方法を誰かに説明してもらえますか?

ご協力いただきありがとうございます。

4

1 に答える 1

1

try this assembly this might help.... atleast it is working for me.

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *arg[])
{
  int retval;
  printf ( " retval = %d \n", retval );
  asm volatile(
           "movl %%ecx , %0\n\t"
           :"=r" (retval));    
  printf ( "retval = %d \n", retval );
  return 0; 
}

prints the following value for me ... I have tried it debugging the second value is same as the value present in ecx register.

p $ecx

command in gdb

> retval = 0  
> retval = -72537468
于 2015-01-01T11:56:48.260 に答える