Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!iuvax!pur-ee!ea.ecn.purdue.edu!housel From: housel@ea.ecn.purdue.edu (Peter S. Housel) Newsgroups: comp.os.minix Subject: alloca() for Minix (was: GNU c and c++ under MINIX) Message-ID: <5396@ea.ecn.purdue.edu> Date: 17 Sep 88 00:10:23 GMT References: <4073@louie.udel.EDU> Reply-To: housel@ea.ecn.purdue.edu.UUCP (Peter S. Housel) Organization: Purdue University Engineering Computer Network Lines: 64 In article <4073@louie.udel.EDU> Leisner.Henr@xerox.com (marty) writes: >I think the gnu tools would be a welcome addition to Minix -- I haven't filtered >through the source code, but the only think I know of which is missing from >Minix would be alloca(). Also the gnu distribution has a plethora of tools. > >I've had terrible luck with the Minix C compiler (everything I port to it has >problems). I quickly recompiled some of my favorite programs on gnu on the >Vaxstation (John Gilmore's tar, Ian Darwin's file) and had no problems. > Funny you should mention alloca()... I'd just been thinking about posting it. It's at the end of this article. I've gotten GNU's bison (yacc replacement) working under Minix with the help of shortc, a program which allows you to compile programs that contain identifiers longer than seven characters. alloca() was required, of course, as well as some tweaking of table sizes. Right now I'm trying gawk, but that's not done yet. Most of the other GNU tools, however, are really such memory hogs that they wouldn't work out. The GCC preprocessor, for instance, malloc()'s a buffer big enough for each input file and modifies it in place. I haven't had such bad luck with the Minix C compiler. You just have to be patient and hack at the program until it compiles. Some nifty things I've got running include: - bison - shortc (available from comp.sources.unix archives) - Allen Holub's NR nroff clone, as published by Dr. Dobbs/M&T (this took about six hours, and it had to be done twice. The result was a halfway decent nroff.) - smail, the uucp mail router. This is still a novelty at the moment. - pathalias, the uucp path router. Ditto. - the public-domain dial(3) modem capability library - SVC, the Shell Version Control system (of course) -Peter S. Housel- housel@ei.ecn.purdue.edu ...!pur-ee!housel -----------------cut here------------------------------------------------ .define _alloca | | alloca() for Minix | by Peter S. Housel 8/15/88 - in the public domain | | Stack frame: | on entry on return | | ... | | ... | | |-----------| <=caller sp |-----------| | | size arg | | | | |-----------| |alloca data| | | ret addr | | ... | | |-----------| <=sp |-----------| <= return value in ax | | dummy word| | |-----------| <= sp | .globl _alloca _alloca: mov bx,sp | bx = sp (for indexing) mov ax,sp add ax,#4 | ax = sp from calling routine sub ax,2(bx) | ax = beginning of alloca block mov bx,0(bx) | save return address mov sp,ax | set new sp push bx | push a random value for caller to remove jmp (bx) | jump back to caller