Table of Contents

Known bugs and limitations

C compiler (gcc-ia16)

Miscompilations involving far function pointers

In some cases, when calling pointers from arrays of far function pointers in optimization modes >= -O1, the code will be miscompiled. This is a known issue, with no ETA for a fix.

One can work around this by annotating the affected function to be compiled without optimizations. In particular, one can create a separate function that only acts as a wrapper for the function call:

__attribute__((noinline, optimize("-O0"))) // https://github.com/tkchia/gcc-ia16/issues/120
void call_to_my_function_table(uint8_t index) {
    my_function_table[index]();
}

Far pointers to near variables

struct a { void __far *ptr; };
struct b { int value; };
struct b instance_b;

// This doesn't work - compiler limitation
const struct a var_ptr = { &instance_b };

// ... but this does
const struct a var_ptr_fixed = { __builtin_ia16_static_far_cast(&instance_b) };

// This doesn't work - __builtin_ia16_static_far_cast only works on variable definitions
const struct a field_ptr = { __builtin_ia16_static_far_cast(&instance_b.value) };

// ... but this does
const struct a field_ptr_fixed = { &(((struct b __far *)__builtin_ia16_static_far_cast(&instance_b))->value) };

wswan/bootfriend: defining interrupt handlers

The wswan/bootfriend target does not support relocation; as such, far functions (which interrupt handlers have to be) cannot be created in sections other than the default text section. This can be achieved by either:

The wwitch target also prohibits defining far functions outside of the default text section, but this only becomes an issue if the FreyaBIOS system APIs (sys_interrupt_set_hook, sys_interrupt_reset_hook) are not used, as those wrap regular C functions.