home *** CD-ROM | disk | FTP | other *** search
- ;80286 version of alloca(), in near code, returns far pointer
- ;assemble with "masm -Ml"
-
- .286
-
- _TEXT SEGMENT WORD PUBLIC 'CODE'
-
- ASSUME cs:_TEXT
-
- PUBLIC _alloca
-
- _alloca PROC NEAR
-
- pop cx ; return address
- pop ax ; amount to alloc
-
- add ax,1 ; round it to 16-bit boundary
- and al,11111110B ;
-
- sub sp,ax ; lower the stack
-
- mov ax,sp ; return ptr to base in ax
- mov dx,ss ; segment of far pointer in dx
-
- sub sp,2 ; allow for 'add sp, 2'
- jmp cx ; jump to return address
-
- _alloca ENDP
-
- _TEXT ENDS
-
- END
-