Search code examples
cprogramming-languagespascallow-levelhigh-level

Low level capabilities of high level languages


I would like to know some low-level capabilities of high-level languages. Off the top of my head I could point out: -bitwise operations -bit fields -pointer arithmetic -inline assembly -interrupt functions

I would apreciate if you pointed out some, that aren't in my list. It would be nice if C or Pascal had them, but basically any high-level language will do. Thank you.


Solution

  • C does not support inline assembler nor interrupts, all C code implementing them is using non-standard compiler extensions. C++ however, has support for inline assembler through the standard.

    Here are some other important, hardware-related features of C:

    • Function pointers are rather unique for C/C++ and makes it possible to execute code located at a specific memory address, and makes it possible to perform other hardware-related tasks. See this for more details of function pointer uses: Function pointers in embedded systems.

    • The integer types. Both C and Pascal support int types of different sizes (byte, word, double word etc), although their sizes are not specified by the standards. For the same reason, the sizeof operator may be important as well.

    • C also has some support for memory alignment, for example explicitly stating rules for how padding bytes should behave.

    • The volatile keyword is also an important feature for hardware-related programming, as it allows variables to be updated in realtime, and without worries about compiler optimizations.

    • The const keyword is used in hardware-related programming to determine where the data will end up: NVM or RAM.

    Other important features that C lacks are multi-threading support as part of the language, and memory barrier support. Some C compilers implement memory barriers through the volatile keyword, but there are no guarantees for it to work by any standard.