home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / alloca.cpp < prev    next >
C/C++ Source or Header  |  1993-01-21  |  684b  |  33 lines

  1. |  alloca(nbytes) allocate junk in stack frame
  2. |
  3. |  void *alloca(size_t size)
  4.  
  5.     .text
  6.      .even
  7.  
  8. .globl    _alloca
  9. _alloca:
  10.     movel    sp@+,a0        | get return addr
  11. #ifndef __SOZOBON__
  12.     movel    sp@+,d0        | get size -- assist in bug fix, add 4 to sp
  13. #else
  14.     clrl    d0        | this size_t thing is getting to be
  15.     movew    sp@+,d0        |  an annoyance...  -- sb
  16. #endif
  17.  
  18.     addql    #1,d0        | ensure address even
  19.     bclr    #0,d0        | lop off odd bit
  20.  
  21.     subl    d0,sp        | increase stack frame size by that much
  22.     movel    sp,d0        | set up to return it
  23.  
  24. #ifndef __SOZOBON__
  25.     lea    sp@(-4),sp    | new top of stack (real bug fix here)
  26. #else
  27.     lea    sp@(-2),sp    | hope this is correct...  -- sb
  28. #endif
  29.  
  30.     jmp    a0@        | return by jmping via saved addr
  31.