C/C ++ & Assembly mixed programming material

In summary: Generally speaking, a good beginner book would be "Beginning C++" by Bjarne Stroustrup (ISBN 978-0-201-63845-5). It covers the basics of C++ and has a good introduction to object-oriented programming. Another book that would be helpful is "Programming C++" by Bjarne Stroustrup and Nicolai Josuttis (ISBN 978-0-201-64109-5). It is a more advanced book, but covers more advanced topics, like templates, exceptions, and threads.
  • #1
pairofstrings
411
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
  • #2
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:
  • #3
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.
 

Related to C/C ++ & Assembly mixed programming material

1. What is the purpose of mixing C/C++ and Assembly in programming?

Mixing C/C++ and Assembly in programming allows developers to take advantage of the high-level and low-level capabilities of both languages. C/C++ provides a structured and efficient way of writing code, while Assembly allows for direct manipulation of hardware and access to specific processor instructions. By combining the two, programmers can achieve a balance of performance and flexibility in their code.

2. What are the advantages of using mixed programming over solely using C/C++ or Assembly?

Mixed programming can provide the best of both worlds - the portability and readability of C/C++ code and the low-level control and optimization of Assembly. This can result in faster execution times and smaller code size, as well as the ability to access and utilize specialized hardware features that may not be available through C/C++ alone.

3. Are there any potential challenges or drawbacks to using mixed programming?

One potential challenge is the need for strong understanding and proficiency in both C/C++ and Assembly languages. Mixing the two can also make code more complex and difficult to maintain. Additionally, some compilers may not support mixed programming, so it may not be a viable option for all projects.

4. How do you determine when to use C/C++ or Assembly in mixed programming?

The decision to use either C/C++ or Assembly in mixed programming depends on the specific project and its requirements. Generally, C/C++ should be used for code that needs to be portable and readable, while Assembly should be reserved for performance-critical sections or hardware-specific operations.

5. Are there any resources or tools available for learning mixed programming?

Yes, there are many resources and tools available for learning mixed programming, such as online tutorials, books, and development environments with support for mixed programming, such as Visual Studio and Eclipse. It is also helpful to have a strong understanding of both C/C++ and Assembly languages before attempting to mix them.

Similar threads

Replies
6
Views
1K
  • Programming and Computer Science
2
Replies
49
Views
3K
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
4
Replies
122
Views
13K
  • Programming and Computer Science
12
Replies
397
Views
14K
  • Programming and Computer Science
Replies
8
Views
953
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
482
  • Programming and Computer Science
Replies
16
Views
2K
  • Programming and Computer Science
4
Replies
107
Views
5K
Back
Top