Nios® V Processor Software Developer Handbook

ID 743810
Date 2/14/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

6.11.6. Use the Minimal Character-Mode API

If you can limit your use of character-mode I/O to very simple features, you can reduce code footprint by using the minimal character-mode API. This API includes the following functions:
  • alt_printf(): This function is similar to printf(), but supports only the %c %s, %x, and %% substitution strings. alt_printf() takes up substantially less code space than printf(), regardless whether you select the lightweight device driver API. alt_printf() occupies less than 1 KB with compiler optimization level -O2.
  • alt_putchar(): Equivalent to putchar().
  • alt_putstr(): Similar to puts(), except that it does not append a newline character to the string.
  • alt_getchar(): Equivalent to getchar().

These functions are appropriate if your program only needs to accept command strings and send simple text messages.

To use the minimal character-mode API, include the header file sys/alt_stdio.h.

The following sections outline the effects of the functions on code footprint.

For more information about the minimal character-mode functions, refer to the HAL API Reference chapter.