35 lines
537 B
C
35 lines
537 B
C
|
#include "syscall.h"
|
||
|
//#include <linux/unistd.h>
|
||
|
#include "start.h"
|
||
|
/*void _init() {
|
||
|
__asm("push %rbp\n"
|
||
|
"movq %rsp, %rbp\n");
|
||
|
}
|
||
|
|
||
|
void _fini() {
|
||
|
__asm("push %rbp\n"
|
||
|
"movq %rsp, %rbp\n");
|
||
|
}*/
|
||
|
|
||
|
void _exit() {
|
||
|
/*__asm__("movl %0, %%eax\n"
|
||
|
"syscall"
|
||
|
:
|
||
|
: "r" (__NR_exit));*/
|
||
|
syscall(__NR_exit);
|
||
|
}
|
||
|
|
||
|
void _start() {
|
||
|
__asm("xor %ebp, %ebp\n"
|
||
|
"mov (%rsp), %edi\n"
|
||
|
"lea 8(%rsp), %rsi\n"
|
||
|
"lea 16(%rsp,%rdi,8), %rdx\n"
|
||
|
"xor %eax, %eax\n"
|
||
|
"call main\n"
|
||
|
"mov %eax, %edi\n"
|
||
|
"xor %eax, %eax\n");
|
||
|
_exit();
|
||
|
}
|
||
|
|
||
|
|