Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. .section .init
  3.  
  4. .global __start
  5. .global __exit
  6. .global __Exit
  7.  
  8. .align 4
  9. __start:
  10.            movl  $68, %eax
  11.            movl  $12, %ebx
  12.            lea  __size_of_stack_reserve__, %ecx
  13.            addl  $4095, %ecx       #load stack size
  14.            andl  $-4096, %ecx      #align to page granularity
  15.            int   $0x40             #and allocate
  16.            testl %eax, %eax
  17.            jz    1f
  18.  
  19.            addl %eax, %ecx
  20.            movl %eax, %fs:4
  21.            movl %ecx, %fs:8        #save stack base - low limit
  22.                                    #save stack top  - high limit
  23.            movl %ecx, %esp
  24.            jmp  ___crt_startup     #reload stack
  25. 1:
  26.            int3                    #trap to debugger
  27.  
  28.            .ascii "No enough memory for stack allocation"
  29.  
  30. .align 4
  31. __exit:
  32. __Exit:
  33.            movl  4(%esp), %edx     #store exit code
  34.            movl  $68, %eax
  35.            movl  $13, %ebx
  36.            movl  %fs:4, %ecx
  37.            int   $0x40             #destroy stack
  38.  
  39.            movl  $-1, %eax
  40.            int   $0x40             #terminate thread
  41.