Assembly? C++?

Started by
2 comments, last by Br3nt0n 18 years, 10 months ago
What is Assembly? What would you use Aseembly for and what would you use C++ for? Pros and Cons.
P4 2.4GHz, GeForce 4 64MB, 512MB of Ram
Advertisement
Assembly is a human-readable form of machine code. It's processor-specific. C++ is a high-level language that is not processor-specific. C++ is much easier to write complex programs in, but there are some things you can't do with it (such as these atomic variable access functions I'm writing), which can only be done in assembly. It's also usually argued that assembly is faster than C/C++, but you have to be very knowledgeable about how the processor works to beat modern optimizing compilers. Not to mention that generally all processors work differently, as far as what is fastest. What blazes on a Pentium may crawl on a Pentium IV (I can think of one specific instance where this would be the case, off the top of my head).

In summary, use C++ whenever you can, and use assembly when you have to.
Expanding on that, assembly is still occasionally used in select areas of an application, where speed is critical. There are some instruction sets that compilers for high-level languages find it hard to leverage effectively (eg, SSE), and writing code directly in assembly to make use of these instructions can provide a significant speed boost. Math libraries still commonly make use of assembly for example.
Thanx for clearing it all up for me
P4 2.4GHz, GeForce 4 64MB, 512MB of Ram

This topic is closed to new replies.

Advertisement