Subversion Repositories Kolibri OS

Rev

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

  1.  
  2.         .global ___chkstk
  3.         .global __alloca
  4.  
  5. .section .text
  6.  
  7. ___chkstk:
  8. __alloca:
  9.         pushl   %ecx            /* save temp */
  10.         leal    8(%esp), %ecx   /* point past return addr */
  11.         cmpl    $0x1000, %eax   /* > 4k ?*/
  12.         jb      Ldone
  13.  
  14. Lprobe:
  15.         subl    $0x1000, %ecx           /* yes, move pointer down 4k*/
  16.         orl     $0x0, (%ecx)            /* probe there */
  17.         subl    $0x1000, %eax           /* decrement count */
  18.         cmpl    $0x1000, %eax
  19.         ja      Lprobe                  /* and do it again */
  20.  
  21. Ldone:
  22.         subl    %eax, %ecx
  23.         orl     $0x0, (%ecx)    /* less than 4k, just peek here */
  24.  
  25.         movl    %esp, %eax      /* save old stack pointer */
  26.         movl    %ecx, %esp      /* decrement stack */
  27.         movl    (%eax), %ecx    /* recover saved temp */
  28.         movl    4(%eax), %eax   /* recover return address */
  29.  
  30.         /* Push the return value back.  Doing this instead of just
  31.            jumping to %eax preserves the cached call-return stack
  32.            used by most modern processors.  */
  33.         pushl   %eax
  34.         ret
  35.  
  36.  
  37.