views:

148

answers:

2

I hear of a need to call assembly functions/calls when programming embedded systems in C. Is this necessary in C++ or not?

+5  A: 

C++ does not provide any more low-level constructs than C does. Hence, if you need to fiddle around with control registers and ISRs in C, you will need to do it in C++.

dirkgently
I understand that C++ does not provide any lower-level constructs than C. But, what do you mean by "you will need to do it in C++" - the statement sounds like a contradiction.
Israel ANY
Ah, I meant that if you _need_ to go down to the level of assembly in C, you will need to do so when using C++ instead. C++ does not offer any advantages in this aspect.
dirkgently
Maybe you can clear up the wording in your question..
Earlz
dirkgently: Got it.Earlz: I think I was specific enough.
Israel ANY
+3  A: 

Calling assembly functions or using assembly calls consists of:

  • Either- inline assembly wrapped in a C/C++ function using the appropriate compiler tag or
  • Another object linked with your executable which was written in assembly that behaves like a C function with respect to the implementation on your system.

So, if you need to use assembly in C, you need to use assembly in C++. That is true not just of embedded programming, too. Take executing the instruction cpuid on intel x86 chips as an example.

Ninefingers