In the Wonderful toolchain, assembly files use the .s extension. They are compiled using the GNU assembler and the C preprocessor.
It is recommended to start with a preamble similar to the following:
#include <wonderful.h> // (1)!
#include <ws.h> // (2)!
.code16 // (3)!
.arch i186 // (4)!
.intel_syntax noprefix // (5)!
Note that to export a symbol (make it visible outside of the specific file, or translation unit), you need to use .global, like so:
.global strlen
strlen:
Including wonderful.h provides some useful macros from ia16.h.
The small and medium targets use different calling conventions (near vs. far functions by default). The following macros abstract these differences away:
call instruction to call C-callable functions.call instruction when calling another function in the same section.jmp instruction to jump to C-callable functions.ret instruction to return from a C-callable function.IA16_CALL_STACK_OFFSET(10) returns 12, but in a far code model, it returns 14.