hi ..i am new to embedded systems ... i am using uvision from keil .. i just wanna include one line assembly code .. into my c-code .. example -- nop (no operation ) assembly instuction into my c code .. how do we do it ??? thanks .. pruthvi
Andy, There is a big difference between fiddling with registers in a C program and inserting a nop. When you are using a processor with pipeline it is sometimes neccessary to use a nop here and there. Using a language extension is not ideal but I perfer it over reverting to assembly just to avoid it.
"There is a big difference between fiddling with registers in a C program and inserting a nop." True - but he only cited the nop thing as an example. Using inline assembler just for a nop is, in itself, a very silly thing to do: as Erik said, it destroys all your source debug info - and for no reason at all because Keil provide the _nop_() intrinsic fubction for this very purpose! Arguments about portability seem pointless here, as the issues concerned are inherently target and/or tool specific! Using inline assembler also overrides uVision's dependency checking, so that such module are always rebuilt - whether they need it or not (and it's a double translation - as Erik also said)
Andy, I think we are in complete agreement. When you said "Don't do it", I thought you meant not to use the intrinsic functions either (which is what both Erik and I recommended). I never use inline assembly, I toyed around with it once and decided it was too much of a headache.