VagrantC
VagrantC

Reputation: 837

Where is Assembly language used to program hardware?

I've looked around for a good place to start learning embedded systems design/programming, and while all suggest beginner devices such as Arduino and RaspberryPi, I've never seen any suggestions for programming at the assembly level. I've recently completed my computer science bachelor's, but I've been getting more and more attracted to hardware rather than software programming. I've taken one hardware design course and we did assembly programming for 68k and logic design in Logism. I have a Raspberry Pi, and have messed with it some, but the languages used for these devices are still higher level (C, C++, Python).

So I have a few questions since I'm really interested in lower level design for chips/computer hardware:

What are the applications of Assembly language in today's hardware design? Is it still widely used or is most of it abstracted by higher level languages?

If it is still widely used, what type of jobs involve Assembly programming? What are the most popular platforms for assembly programming (68k, x86, etc.)?

Finally, what are some resources for modern-day Assembly programming, if the above applies?

Thanks, and again I've looked at some of the other questions about diving into embedded systems, so I hope my questions are sufficiently different, but feel free to flag this if my questions were already answered!

Upvotes: 0

Views: 8644

Answers (3)

Krystian Sakowski
Krystian Sakowski

Reputation: 1653

What are the applications of Assembly language in today's hardware design? Is it still widely used or is most of it abstracted by higher level languages?

Assembly language is used in specific use cases. It is still the most common in specific use cases in embedded systems software however it is still present in other low level projects like Linux kernel. It is used here and there because there are certain things then can be done only in assembly and because assembly results in a faster and smaller code. I will give you one real life example to make it more clear to you. Some critical parts of firmware for smart cards is written in assembly in order to protect software execution against different types of attacks and assembly is the only language where you fully control binary representation of the program. Compiler might leave security hole in the firmware which might be an entry point for the attacker.

If it is still widely used, what type of jobs involve Assembly programming?

Here you have few example engineering positions requiring advanced assembly language knowledge:

  • Compiler Engineer.
  • Firmware Engineer.
  • Secure Firmware Engineer.
  • Malware Analyst.

What are the most popular platforms for assembly programming (68k, x86, etc.)?

Check the most popular CPU architectures in these times and you will have the answer (spoiler Intel x86/x64, ARM).

Finally, what are some resources for modern-day Assembly programming, if the above applies?

Google

Upvotes: 7

user5069935
user5069935

Reputation:

What are the applications of Assembly language in today's hardware design? Is it still widely used or is most of it abstracted by higher level languages?

It is still very common in low-level electronics design, meaning embedded micro-controllers rather than microprocessors usually.

If it is still widely used, what type of jobs involve Assembly programming? What are the most popular platforms for assembly programming (68k, x86, etc.)?

Electronics hardware designers still routinely use assembly for time-deterministic or speed-critical operations (usually small parts of a larger high-level language application running as firmware loaded from flash into a microcontroller).

Some chips still commonly programmed with assembly language are Atmel, Microchip PIC, Cypress, Parallax, Renesas, MSP430. I would be surprised to see much large scale use of assembly language for larger applications on big iron such as Intel processors or anything running a non-RTOS.

"Use assembly when nanoseconds matter, otherwise stick to high level." is the approximate rule of thumb in the industry.

Upvotes: 0

Clifford
Clifford

Reputation: 93554

What are the applications of Assembly language in today's hardware design? Is it still widely used or is most of it abstracted by higher level languages?

There are few reasons to use assembler for device-level programming. Systems-level languages such as C and C++ can run on stand-alone, bare-metal systems with few resources and no OS. In the past is was common to resort to assembler to implement time critical code sections (often with little evidence of necessity in my experience), but with modern optimising compilers that is seldom necessary, and the compiler encapsulates instruction set expertise that would take a human many hours to learn for just a single architecture - so the compiler will often beat a human on performance.

Developers that have spent years honing their assembler skills for one architecture may be justifiably proud of their achievement, but are often reluctant to consider new architectures because their architecture specific skills that might allow then to beat a compiler are redundant, and are often reluctant to admit that a modern compiler can often achieve better results overall, because that would invalidate their previous hard work. If you have to move fast (and generally there is a commercial imperative to do so), the assembler is not the way to do that, and I would be wary of the developer advocating teh use of assembler without first failing to achieve the necessary results in C or C++ (or ADA or Forth - anything but assembler).

I would not write assembler developers them off as dinosaurs perhaps (actually I would - but I am trying to be polite ;-) ), but outside of the lowest level of system bootstrap, interrupt handling or context switch (which is often provided by existing code or libraries in any case), assembler is something you resort to when necessary rather that plan to use from the outset - that is generally a "premature optimisation".

If it is still widely used, what type of jobs involve Assembly programming? What are the most popular platforms for assembly programming (68k, x86, etc.)?

Its not. Very few. In over 25 years in embedded development in real-time systems I have seldom written any assembler, but sometimes have needed to be able to read it - often compiler generated assembler.

Where assembler code is necessary is in areas where the high-level language cannot reach, which applies to access to non-memory mapped core CPU registers. Such access is necessary for example to implement context switching in an RTOS - but that code can be very small and "boiler-plate" copied - you need not necessarily write such code yourself. See here for example, where small sections of in-line assembler are used within mostly C code to effect a task scheduler on ARM Cortex-M.

On architectures with non-memory mapped I/O, there are usually inp/outp instructions that require assembler to implement, though often this is provided by a C function interface by a target library or compiler intrinsic. For memory mapped I/O there is nothing in C or C++ that prevents access to arbitrary memory addresses. The target hardware however may implement privilege levels or memory protection that restricts such access, managing such protection may need code that cannot be implemented in a high level language; but again library or intrinsic support is generally provided.

On ARM Cortex-M it is possible to run C code directly from the reset vector and to implement interrupt handlers entirely in C code with no assembler glue - so increasingly in some cases assembler is unnecessary.

Finally, what are some resources for modern-day Assembly programming, if the above applies?

Most C and C++ tool-chains include a standalone macro-assembler and support in-line assembly (mixed C and assembler code), and the associated source level debuggers support instruction level debugging too.

Upvotes: 1

Related Questions