A language fit for embedded

By Colin Walls

Embedded Software Technologist

June 14, 2017

Blog

A language fit for embedded

There are a great many programming languages in use today and many more that have fallen into disuse over the years. A challenge has always been standardization. Just about everyone would concur...

There are a great many programming languages in use today and many more that have fallen into disuse over the years. A challenge has always been standardization. Just about everyone would concur that standards are a Good Thing, but nobody can agree on how to apply the idea to programming languages.

One approach is to design a very complete language that addresses every programmer’s needs. This was attempted about 50 years ago by IBM. In those days, there were a number of widely used languages for different purposes. COBOL dominated the world of data processing, whereas the language of choice for engineers and scientists was generally Fortran. IBM created PL/1, which was an enormous language, with a very wide range of capabilities. It was quite widely used (on IBM mainframes), as programmers mostly found that it did indeed have the functionality that they required. The problem was that every user learned a different subset of the language, depending on their needs. It was thus quite possible for two PL/1 programmers to be unable to understand one another’s code.

The alternative tactic is to create a very lean language specification and accept that the language will be adapted to specific needs. This is what happens in the world of embedded software, where the dominant languages are C and C++. Neither of these languages were designed for embedded programming, but fit the needs of developers quite well. Their shortcomings are addressed in three ways:

Language extensions – extra keywords

An obvious way to enhance the usability of a language is to extend the range of keywords. Obviously, this practice should be minimized to avoid straying too far from the standard. For embedded developers, four extra keywords are favored: interrupt (which enables interrupt service routines to be coded in C), asm (which enables lines of assembly language to be inserted) and packed and unpacked (which override the prevailing memory usage optimization policy).

Inline compiler directives – #pragma

Although such directives are quite flexible, they do result in compiler-specific code, which may be inconvenient.

Linker capabilities

A major concern for embedded software developers may be the location of code/data in memory, where being able to map on to custom hardware configurations is essential. As a result, the linker is an invaluable tool, as it addresses this matter, which is largely ignored by the programming languages.

Colin Walls is an Embedded Software Technologist at Mentor Graphics’ Embedded Software Division.

My work in the electronics industry spans nearly 40 years, almost exclusively with embedded software. I began developing software and managing teams of developers.Then, I moved to customer roles, including pre-and-post sales technical support, sales management and marketing. I have presented at numerous conferences, including Design West, Design East, Embedded World, ARM TechCon, and my work frequently appears on Embedded.com.

More from Colin

Categories
Software & OS