2011-08-12 2 views
0

현재 MS VS IDE에서 생성 된 코드를 수정하고 있으며, 변경해야 할 사항은 __declspec (naked)에서 __attribute__ ((naked))으로 변경하는 것입니다.__declspec (naked)에 해당하는 g ++에 해당하는 매개 변수 전달은 어떻게 작동합니까?

그러나 변경 한 후에는 프로그램에서 매개 변수를 올바르게 액세스하고 변경하지 않습니다.

__attribute__ ((naked))을 사용하면 매개 변수 전달이 다릅니 까? 어떤 도움이 많이 감사합니다

//Main file 
#include <stdlib.h> 
#include <stdio.h> 

extern void test(int * arrayToSort, int size); 


int main(int argc, char ** argv) { 
    int * a = (int*) malloc (sizeof(int) * 10); 

    int j; 
    for (j=0; j<10; j++) 
    { 
     printf("a[%d]=",j); 
     scanf("%d",a+j); 
     printf("\n"); 
    } 

    test(a, 10); 

    for (j=0; j<10; j++) 
    { 
     printf("%d ", a[j]); 
    } 
    printf("\n"); 
} 

//test code file 
void test(int * array, int size) 
{ 
    _asm { 
     push edx 
     push ecx 
     push ebx 
     push eax 

     mov eax, dword ptr[esp+20] //*array 
     mov ebx, dword ptr[esp+24] //size 

     mov dword ptr[eax], 25 //array[0] = 25 
     mov dword ptr[eax+4], ebx //array[1] = size 

     pop eax 
     pop ebx 
     pop ecx 
     pop edx 
    } 
} 

: 여기

는 코드입니다.

시스템 사양 :

맥북 프로 늦은 2009 인텔 코어 2 듀오 2.66 OS X 라이온

현재 편집 지침 실행 GHz의 다음 GNU documentation에서

g++ -fomit-frame-pointer -m32 -fasm-blocks -o QS Test.cpp Main.cpp 

답변

0

을 :

알몸을
사용하기 ARM, AVR, MCORE, RX 및 SPU 포트의 s 속성을 사용하여 지정된 함수가 컴파일러에 의해 생성 된 프롤로그/에필로그 시퀀스를 필요로하지 않음을 나타냅니다.

__attribute__((naked))은 현재 x86 또는 x86-64에서 지원되지 않습니다.

관련 문제