This example shows how to do a Linux system call using inline assembly.
By pinning the gpr
and the interrupt instruction int
, you can create your own print
function.
print :: (str: string) {
len := str.count;
msg := str.data;
#asm {
mov edx: gpr === d, len;
mov ecx: gpr === c, msg;
mov ebx: gpr === b, 1;
mov eax: gpr === a, 4;
int 0x80;
}
}
print("Hello World!\n"); // prints "Hello World!\n".