home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel Volume 2 #1
/
carousel.iso
/
mactosh
/
lang
/
mpw_c_gr
/
alloca.a
next >
Wrap
Text File
|
1988-10-10
|
773b
|
23 lines
;;
;; Alloca() for Macintosh Programmer's Workshop C.
;; alloca(n) allocates n bytes of storage in the stack
;; frame of the caller.
;;
;; APPLE APPLE APPLE APPLE APPLE APPLE APPLE APPLE APPLE APPLE
;; MACINTOSH MACINTOSH MACINTOSH MACINTOSH MACINTOSH MACINTOSH
CASE ON
alloca PROC EXPORT
move.l (sp)+,a0 ; pop return address
move.l (sp)+,d0 ; pop parameter = size in bytes
add.l #3,d0 ; round size up to long word
and.l #-4,d0 ; mask out lower two bits of size
sub.l d0,sp ; allocate by moving stack pointer
move.l sp,d0 ; return pointer
add.l #-4,sp ; new top of stack
jmp (a0) ; return to caller
ENDP
END