home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / sozobon / alloca.s next >
Text File  |  1992-02-12  |  485b  |  23 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.     move.l    (sp)+,a0    ; get return addr
  11.     move.w    (sp)+,d0    ; get size -- assist in bug fix, add 2 to sp
  12.  
  13.     addq.w    #1,d0        ; ensure address even
  14.     bclr    #0,d0
  15.  
  16.     sub.w    d0,sp        ; increase stack frame size by that much
  17.     move.l    sp,d0        ; set up to return it
  18.  
  19.     subq.l    #2,sp        ; new top of stack (real bug fix here)
  20.  
  21.     jmp    (a0)        ; return by jmping via saved addr
  22.