inline assembly error

Question!

I am using inline assembly for iphone, I working for device debug mode.

The instruction is as follows:

__asm__("smlatb %0, %1, %2 ,%3 \n\t": "=r"(Temp): "r"(treg5) : "r"(fac5) : "r"(Temp) );

And I am getting an errors:

error : expected ')' before tokedn '(' error: unknown register name 'r' in 'asm'

I am using X-code 3.0 and gcc 4.0. Any ideas?



Answers

There should only be three colons, not four.

The arguments following the first colon specify the inputs, then the outputs, then the clobber list.

If you have multiple parameters you can use a comma to separate them rather then colon.

In your example. I assume, that temp is your output and treg5, fac5 are your inputs. You probably want something like this.

__asm__("smlatb %0, %1, %2, %0 \n\t"
        : "=r"(Temp) 
        : "0"(Temp), "r"(treg5), "r"(fac5)
        :);

Btw, there are some good examples of iphone ARM assembly in the vfpmath library.



You have got too many : (colons). They are used as separators. So, you should have one to separate the assembly code with the output variable, and one to separate the output variable from the input variables. It's something like asm ("assembly" : <output> : <inputs> : [extra attributes]). Look up 'inline assembly' for GCC and you will see some examples.

By : sybreon


Hi finally I added codewarrior style inline assembly __asm{ smlatb Temp, treg5, fac5 ,Temp } and in prject settings under build tab under GCC 4.0 language I selected the option Allow CodeWarrior-Style Inline Assembly also selected allow 'asm' 'inline' 'typeof' options and the code worked finally

By : Manish


This video can help you solving your question :)
By: admin