crt0.s 420 B

123456789101112131415161718192021222324252627
  1. .code32
  2. .text
  3. # TODO: call .init and .fini, initialize c standard library
  4. .globl _start
  5. .type _start @function
  6. _start:
  7. movl (%esp), %eax # argc
  8. leal 4(%esp), %ecx # argv
  9. movl %esp, %edx
  10. andl $0xfffffff0, %esp
  11. pushl %edx
  12. pushl $0
  13. movl %esp, %ebp
  14. pushl %ecx
  15. pushl %eax
  16. call main
  17. movl %eax, %edi # code
  18. movl $0x05, %eax # SYS_exit
  19. int $0x80 # syscall