assembly and c++/C

Ok so on friday am having my exams in assembly...I did c++ before assembly...and after these assembly lessons I think knowing assembly even helps to write better c or c++ code...although i have not tried it..i have the thinking going on that a part of a code in c / c++ can be debugged trying to write it in assembly...
what do you guys think?
that a part of a code in c / c++ can be debugged trying to write it in assembly


I don't really understand you here. Are you asking whether you can write assembly in C++? With GCC at least, you can inline assembly using __asm to your source files (using AT&T syntax). Look it up if you want to know more, I don't really use it.

As for whether assembly helps you write programs better in C or C++, my experience is not really for C++ and a bit for C, though all it did was show me little workarounds I could use for a few problems I had at the time...

No, assembly is really used so that you can have the finest control over your program, while C and C++ kind of abstract that a bit (compared to assembly, C++ especially is 'high level').
The optimizer knows a lot more than we think it does. It consistently performs flow analysis, applies all the optimisation techniques discovered by many programmers over years (programmers who write the compiler have collectively spent a huge amount of time studying these). As opposed to the handful of techniques a single programmer might have learnt so far, and can actually recognize that in a particular situation one of them can be profitably used.

There are places where inline assembly code in C++ should be written, but these are rare.

Some valid examples would be:

- Early bootstrap of a processor before the environment to support compiled C/C++ code is brought up.

- Implement macros in <cstdarg> ( va_start, va_arg, va_end ) on certain platforms

- Implement specializations for std::atomic<IntegralType>, std::mutex and the like on certain platforms

- Implement cross-address-space thunks or trampolines on some platforms.

- Optimized implementation of library functions via intrinsics eg. std::memcpy(), std::uninitalized_fill(), std::llround(), std::accumulate() etc.
Topic archived. No new replies allowed.