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:
wonderful.h
provides some useful macros:
call
instruction to call C functions.jmp
instruction to jump to C functions.ret
isntruction to return from a C-called function.WF_PLATFORM_CALL_STACK_OFFSET(10)
returns 12
, but in a “far” code model, it returns 14
.