Files
brightstone/Player/Main/linux-x86.c
T
2026-10-08 10:50:42 +03:00

27 lines
1.0 KiB
C

/* No libc starting point. Jump straight into action! */
__attribute__((naked)) __attribute__((force_align_arg_pointer))
__attribute__((noreturn)) extern void
_start(void) {
__asm__ volatile("xorl %ebp, %ebp\n"
"movl (%esp), %ecx\n"
"leal 4(%esp), %edx\n"
/* 3. Align the stack pointer to a 16-byte boundary */
"andl $-16, %esp\n"
/* 4. Reserve stack space for main's arguments + padding
We need to pass 2 arguments (8 bytes).
To keep %esp 16-byte aligned before the "call",
we allocate 16 bytes total. */
"subl $16, %esp\n"
/* 5. Place arguments onto the newly aligned stack */
"movl %ecx, (%esp)\n"
"movl %edx, 4(%esp)\n"
"call plr_display_x11_main\n"
"movl %eax, %ebx\n"
"movl $1, %eax\n"
"int $0x80");
}