2016년 10월 28일 금요일

인라인 어셈블

c코드 안에 어셈블리어를 쓰는 방식
ARM 아키텍처 환경(라즈베리파이)에서 테스트 해보았다.
gcc -o asm asm.c 로 하면 컴파일이 잘 되고 결과도 잘 나옴.

[코드]

#include <stdio.h>

int  asm_bic_ex ( int x, int y);

asm(" \n\
.global asm_bic_ex \n\
asm_bic_ex: \n\
bic r0, r0, r1 \n\
mov pc, lr     \n\
");

int main ( void )
{
int  bic;

printf("\n+-------------------+\n");
printf("|ARMInstruction BIC|\n");
printf("+-------------------+\n\n");

bic = asm_bic_ex( 0x1111, 0x1010);        

printf("cpsr = %08X\n\n", bic );

return 0;
}

[결과]



출처
ARM 명령어를 배워보자(19) : bic
http://forum.falinux.com/zbxe/index.php?document_srl=572163&mid=lecture_tip

댓글 없음:

댓글 쓰기

clear images were obtained