home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / lang / mpw_c_gr / alloca.a next >
Text File  |  1988-10-10  |  773b  |  23 lines

  1. ;;
  2. ;; Alloca() for Macintosh Programmer's Workshop C.
  3. ;; alloca(n) allocates n bytes of storage in the stack
  4. ;; frame of the caller.
  5. ;;
  6. ;; APPLE APPLE APPLE APPLE APPLE APPLE APPLE APPLE APPLE APPLE
  7. ;; MACINTOSH MACINTOSH MACINTOSH MACINTOSH MACINTOSH MACINTOSH
  8.  
  9.     CASE ON
  10.     
  11. alloca PROC EXPORT
  12.         move.l  (sp)+,a0        ; pop return address
  13.         move.l  (sp)+,d0        ; pop parameter = size in bytes
  14.         add.l   #3,d0           ; round size up to long word
  15.         and.l   #-4,d0            ; mask out lower two bits of size
  16.         sub.l   d0,sp           ; allocate by moving stack pointer
  17.         move.l  sp,d0           ; return pointer
  18.         add.l   #-4,sp          ; new top of stack
  19.         jmp     (a0)            ; return to caller
  20.         ENDP
  21.         END
  22.         
  23.