2

I have this part of code that was compiling using ARMASM :

/* Software Interrupt */
/* we must save lr in case it is called from SVC mode */
#define ngARMSwi( code)   __asm { SWI code,{},{},{lr} }

example of use : ngARMSwi( 0x23);

I try to convert this to compile using gcc (code sourcery GCC-4.6.2 eabi). I found this link http://www.ethernut.de/en/documents/arm-inline-asm.html but I cannot find a way to compile this line correctly.

my best try is

#define ngARMSwi( code)  __asm__ ("SWI " (code) : : :"lr" )

but I get compile error :

error: expected ':' or ')' before '(' token

Any help is appreciated!

1 Answer 1

1

You probably want

#define ngARMSwi(code) __asm__("SWI %0" : : "I"(code) : "lr")

Note that code is an input to the instruction, so it goes in the third section. Its place in the instuction is marked by the %0 in the string. The I is a constraint on code, indicating that it must be an 8-bit constant.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! This code compile... I just have to make sure now that it does the same thing as previously!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.