Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!usc!srhqla!quad1!avatar!kory From: kory@avatar.UUCP (Kory Hamzeh) Newsgroups: comp.unix.xenix Subject: Re: alloca function needed Summary: Here it is. Message-ID: <124@avatar.UUCP> Date: 12 Dec 89 23:42:16 GMT References: <718@buddha.UUCP> Distribution: na Organization: Kory Hamzeh, Canoga Park, Ca, USA Lines: 122 In article <718@buddha.UUCP>, rodeen@buddha.UUCP (Rick Odeen) writes: > If anyone has an alloca function for Xenix or knows where one is archived > I would appreciate it. Here is a version that Chip Salzenberg posted here awhile ago: #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Makefile' <<'END_OF_FILE' X# Makefile for alloca X XTARGET=Sliballoc.a XASFLAGS=-Mx $(LISTING) X Xall: $(TARGET) X Xclean: X rm -f *.o ?liballoc.a X XSliballoc.a: alloca.s X $(AS) $(ASFLAGS) -DMODEL_$(MODEL) -oalloca.o alloca.s X ar ru $@ alloca.o X rm alloca.o X ranlib $@ END_OF_FILE if test 236 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'alloca.s' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'alloca.s'\" else echo shar: Extracting \"'alloca.s'\" \(1075 characters\) sed "s/^X//" >'alloca.s' <<'END_OF_FILE' X; alloca.s X; Allocate from the stack from a Microsoft C program. X X TITLE $alloca386 X X .386 X X_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' X_DATA ENDS XCONST SEGMENT DWORD USE32 PUBLIC 'CONST' XCONST ENDS X_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' X_BSS ENDS XDGROUP GROUP CONST, _BSS, _DATA X X_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' X_TEXT ENDS X X ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP X_TEXT SEGMENT X X PUBLIC _alloca X X_alloca PROC NEAR X X;; Pop return address into edx and size into eax X pop edx X pop eax X X;; Make sure that eax is greater than zero, and is a multiple of four. X cmp eax,0 X jg short pos X mov eax,4 Xpos: X add eax,3 X and eax,not 3 X X;; Remember old stack pointer X mov ecx,esp X X;; Figure new stack pointer, our return value. X sub esp,eax X mov eax,esp X X;; Copy the (hypothetical) register variables. X push [ecx+8] X push [ecx+4] X push [ecx+0] X X;; Put something on the stack so that our caller can pop it off. X push eax X X;; Return to the the caller. X jmp edx X X_alloca ENDP X X_TEXT ENDS X X END END_OF_FILE if test 1075 -ne `wc -c <'alloca.s'`; then echo shar: \"'alloca.s'\" unpacked with wrong size! fi # end of 'alloca.s' fi echo shar: End of shell archive. exit 0 -- ------------------------------------------------------------------------------- Kory Hamzeh UUCP: avatar!kory or ..!uunet!psivax!quad1!avatar!kory INTERNET: avatar!kory@quad.com