You copied the Doc URL to your clipboard.

Using $Sub$$ to mix semihosted and nonsemihosted I/O functionality

You can use $Sub$$ to provide a mixture of semihosted and nonsemihosted functionality.

For example, given an implementation of fputc() that writes directly to a UART, and a semihosted implementation of fputc(), you can provide both of these depending on the nature of the FILE * pointer passed into the function:

int $Super$$fputc(int c, FILE *fp);
int $Sub$$fputc(int c, FILE *fp)
{
    if (fp == (FILE *)MAGIC_NUM) // where MAGIC_NUM is a special value that
    {                            // is different to all normal FILE * pointer
                                 // values.
        write_to_UART(c);
        return c;
    }
    else
    {
        return $Super$$fputc(c, fp);
    }
}
Was this page helpful? Yes No