inlineAsmDemo

This example (inlineAsmDemo directory) illustrates utilizing the inline assembly feature. The inline assembly feature allows you to embed assembly language code into your high-level code such as C and C++ whenever you need to implement low-level operations or improve the performance.

The following are demonstrations of inlineAsmDemo applications
  • Integer arithmetic operations
  • Looping implementation
  • if-else implementation
  • Memory access
  • Proper use of general-purpose register (x0 – x31)
  • Exchange of values between the inline assembly and C

This example provides both C and assembly language for the same implementation for easier understanding and further includes the following definition to use the C language implementation.

#define C_IMPLEMENTATION 1

This application increments the LEDs until all LEDs are enabled and waits for the UART input character 'r'. Once received, the LEDs will be reset for increment again.

The UART terminal prints these messages when C_IMPLEMENTATION is defined.

Inline Assembly Demo

Demonstrating C implementation

Reset the LEDs by pressing 'r'

The UART terminal prints these messages when C_IMPLEMENTATION is not defined and inline assembly is used.

Inline Assembly Demo

Reset the LEDs by pressing 'r'

Refer to Inline Assembly to understand more about inline assembly and its application.