home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c220 / 4.ddi / ETC / ALLOCA.ASM next >
Encoding:
Assembly Source File  |  1990-12-16  |  649 b   |  27 lines

  1.     include    model
  2.     cseg    alloca_
  3. ;
  4. ;  MetaWare Runtime Support: alloca.
  5. ;  (c) Copyright 1989 MetaWare, Incorporated    
  6. ;  Entry:
  7. ;    size to alloc
  8. ;    return address    <- SP
  9. ;  Exit:
  10. ;    alloc-ed space
  11. ;    4 bytes of junk
  12. ;  since C will pop the 4 bytes of junk.    
  13.     public    alloca
  14. alloca  proc    near
  15.     mov    edx,0[esp]    ; Get return address
  16.     mov    eax,4[esp]    ; Amount to alloc.
  17.     add     eax,3h          ; Align to 4-byte boundary
  18.     and     al,0fch
  19.     ; We don't do stack-limit checking, so
  20.     sub     esp,eax         ; make sure you have the stack space available!
  21.     mov    eax,esp
  22.     add    eax,4        ; 
  23.     jmp    edx        ; return
  24. alloca  endp
  25.     endcseg    alloca_
  26.     end