views:

471

answers:

6

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?

A: 

one correction the instruction is asm("smlatb %0, %1, %2 ,%3 \n\t": "=r"(Temp): "r"(treg5) : "r"(fac5) : "r"(Temp) );

Manish
I edited the original question to include this updated information.
unwind
A: 

I believe you should be doing something like this:

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

See this Stack Overflow question for details.

Naaff
Hi I have done that ie added 2 underscore characters before and after asm still I am getting same error.
Manish
A: 

HI NAFF I have done the correction suggested by you its just that I dont know how the underscore in my questions disapperead. Even with succeding and preceding underscores I am getting same error message

Manish
Put a backslash before the underscore or it will be treated as a markdown tag: \_
bdonlan
A: 

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

Manish
A: 

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.

sybreon
Thanks looking at examples solved my problem
Manish
Dude, at least up-vote or accept an answer. :)
sybreon
A: 

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.

hyperlogic