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
2010-02-08 23:28:34
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
2010-02-08 23:35:43
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
2010-02-08 23:37:44
Maybe you can clear up the wording in your question..
Earlz
2010-02-08 23:40:15
dirkgently: Got it.Earlz: I think I was specific enough.
Israel ANY
2010-02-08 23:47:18
+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
2010-02-08 23:30:15