Someone posted a link recently on Slashdot entitled "Obsolete Technical Skills", one of which was assembly language programming. Actually, I'd have to agree that its obsolete to program in assembly language, in every industry except embedded. Also obsolete is trying to fit your code into less than 64K of memory or trying to get your program to run on 2K RAM, in every industry except embedded. Why do we need to struggle with these issues? Because the universal design principle of embedded engineering is:

Design it to be as cheap as possible and still be functional

I like to call this the "Cheapskate Postulate" and this is universal in almost any manufacturing industry. This means that if you can use a $1 8-bit 8051 instead of $10 32-bit ARM, then you should do it. 

And what's the best way to reduce your code size and RAM usage, hence minimizing cost? And the best way to improve performance when you have to use a slower processor? Hint: NOP, JMP, JNE. 

 The second best way to reduce your code size and improve your performance is to write your software in C. I'm not sure if anyone's ever tried to write a Java OS, but I'm sure it'll be slow as shit.

Embedded design is done as close to the hardware as possible because embedded engineers don't trust everything to work correctly. The less things in between your software and your hardware, the better, and the best way to get to the metal is through assembler. Thats where you are just writing macros that directly translate into machine language (hex op codes). C is usually a better choice if you need to write portable (or maintainable) code, but you take a hit on the code size and performance. If you use a high level language to do embedded programming such as Java or Python, then you need to run through an interpreter which is just another chance for things to go wrong. Plus you have no control over the memory since the garbage collection is automatic. 

C++ is also not an optimal choice in many cases because, although it may lead to portable/reusable (and obfuscated) code, the language constructs translate into many, many operations when compiled. An example would be at a company I used to work at. There were two USB drivers, one written in C++ and one written in C. The software engineers fresh out of the university wanted to use C++ because they couldn't understand why anyone would want to use a non-OOP, obsolete language in C. So their code weighed in at 100KB. The code was then re-written in C after the company got pummeled by cheap Taiwanese chip companies that offered a lower overall bill of materials (ie: the total package was cheaper because it used less memory). The code then weighed in at less than 20 KB. I'm sure you could have made more savings if you wrote it in ASM, but I wouldn't want to try and maintain or support it.

So that, in a nutshell, is why C and ASM are obsolete...except in embedded programming.

You have no rights to post comments