Creating your own Print function in Assembly Language (Linux syscall)

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".
1 Like