C/C ++ & Assembly mixed programming material

AI Thread Summary
For expertise in mixed C/C++ and assembly programming for embedded systems, it's essential to understand that most source modules are typically written in a single language to avoid optimizer issues. Assembly is mainly used for small, critical routines and low-level hardware interactions, particularly in systems like ARM. Learning how parameters are passed in function calls and how names are mangled in C/C++ is crucial for effective mixed programming. It is advisable to consult architecture manuals for specific platforms to optimize routines and understand instruction sets. Overall, while resources for C/C++ are abundant, specialized books on mixed programming may be harder to find.
pairofstrings
Messages
411
Reaction score
7
Can anyone suggest me good books on 'C/C ++ & assembly mixed programming' for embedded system coding. I am trying to gain expertise in mixed C/C++ & assembly mixed programming for writing embedded system codes. I am fairly new to mixed programming. I know C/C++ and assembly languages. Now, I need to know mixed programming. Can you please suggest me any good books for mixed programing.
 
Last edited:
Technology news on Phys.org
If you know C++ and assembly, then you're almost there already. I've worked on embedded systems, and normally each source module is all C, C++, or assembly, and not mixed (no _asm() directives used in C code, because it interferes with the optimizer). Generally the amount of assembly code is small, mostly for the operating system used in a device, and perhaps some time critical routines. In the case of a cpu with a lot of registers, like an ARM with 16 registers, it's difficult to improve on the optimization of the code, but you need assembly to deal with context switching and dealing with interrupts (ARM uses secondary shadow registers for fast interrupt, normal interrupt, supervisor mode, ... ), or any math routine that needs to use low level hardware like the carry bit or paired registers.

The other thing to learn is how parameters are used in calls (registers versus stack), and how names are "mangled" in C or C++ so you can use the proper parameters and names in assembly. This can usually be done by writing a test module in C or C++ and having the compiler produce assembly code, which gives you the parameter setup and names.

Unless you get involved with the operating system itself, there's not much to learn. Most companies will just buy a basic operating system or hire a consultant if no one in house is famliar with the internals of an operating system.
 
Last edited:
pairofstrings said:
Can anyone suggest me good books on 'C/C ++ & assembly mixed programming' for embedded system coding. I am trying to gain expertise in mixed C/C++ & assembly mixed programming for writing embedded system codes. I am fairly new to mixed programming. I know C/C++ and assembly languages. Now, I need to know mixed programming. Can you please suggest me any good books for mixed programing.

For the assembler, it's probably a good idea to get the specific architecture manuals for the platform you are using. Get both the manuals that outline the instruction set complete with opcodes and binary representation (just in case you can't get an assembler).

Also in the architecture manuals it should give details about the flow control of the hardware platform: this is the key thing you need for optimization and critical routines.

As an example of what I'm talking about, when the pentium chip came out from intel, there was a thing called a U and V pipe. Now the pentium chip had only one core and one main CPU, but if you put certain instructions in a certain order it could process them quicker due to the UV pipe architecture. If you are interested in fast optimized code, its the tricks like this that will give you the speed edge.

As for C/C++, there are plenty of resources out there and its hard to give recommendations for that.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top