libx86 - a hardware-independent library for executing real-mode x86 code

What is it?

It's often useful to be able to make real-mode x86 BIOS calls from userland. lrmi provides a simple interface to this for x86 machines, but this doesn't help on other platforms. libx86 provides the lrmi interface, but will also run on platforms such as amd64 and alpha.

How does it work?

libx86 is built on top of two bodies of code - lrmi and x86emu. x86emu is a generic x86 emulator originally provided by Scitech and now maintained as part of the distribution.

On x86 platforms, libx86 will use the vm86 interface provided by most modern kernels in order to execute code. On non-x86 platforms, an interface layer is provided to allow x86emu to be used to execute lrmi function calls. The API is identical in both cases, meaning that applications can be written without having to care about what's going on behind the scenes.

How do I use it?

If you already have an lrmi-using application, simply:

If not, here is some sample code for a trivial libx86 application. It simply executes the code found at address c000:0003.

#include <libx86.h>
#include <stdio.h>

int main() {
    struct LRMI_regs r;
    memset(&r, 0, sizeof(r));
    r.cs = 0xc000;
    r.ip = 0x0003;


    if (!LRMI_call(&r)) {
        fprintf(stderr, "Error: Something went wrong performing realmode call\n";

Where do I get it?


Who wrote it and what license is it under?

Check the package for the precise licensing terms - the details vary slightly between the different sections of code, but effectively you can do whatever you want with the code (including incorporating modified versions into your non-free application) providing that the copyright notices are maintained.

What needs to be done?