2017-11-24 19 views
1

C에서 인라인 어셈블리 코드로 Atomic LDSET ARM 명령어 (http://www.keil.com/support/man/docs/armclang_asm/armclang_asm_chi1476202820379.htm)를 사용하려고하지만 어떻게 든 올바른 피연산자를 파악할 수 없습니다. 나는이LDSET 인라인 어셈블리 인 ARM 명령어

int value = 1024; //operate on this value 
int setBit = 7; //set the 7th bit 
int initValue = 0; //return the original value in this 
asm("ldset %w0, %w2, %x1" : "+r"(value), "=r"(initValue) : "r"(setBit)); 

을 쓴이 오류 가지고 :

test-lib.cpp:26:9: error: invalid operand for instruction 
    asm("ldset %w0, %w2, %x1" : "+r"(value), "=r"(initValue) : "r"(setBit)); 
    ^
<inline asm>:1:17: note: instantiated into assembly here 
     ldset w9, w10, x10 
        ^

이에 도움을 주시기 바랍니다이 필요합니다.

답변

1

page you linked에 따르면 세 번째 피연산자는 메모리 참조 여야하며 오프셋없이 단일 레지스터 만 사용하는 피연산자 여야합니다. Q constraint is for specifically this purpose, 그래서 시도 :

asm("ldset %w0, %w2, %1" : "+r"(value), "=Q"(initValue) : "r"(setBit)); 

ldset w0, w1, [x2] 같은 것을 생성해야합니다.