TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Peter Collis
from: David Nugent
date: 1996-06-24 00:18:08
subject: Find a word

> > looks like without local varables the BP/SP reg's are not saved
 > > and restored when optimizations are turned on.

 > DN> I'd consider that a bug in QC's alloca() implementation. AFAIK,
 > DN> MSC had no problems in any versions I used (2, 4, 5, 5.1, 6, 7).

 > I've always assumed QC and MSC-6 shared some of the help files, If
 > you have MSC6 installed check out the online help for alloca() and see
 > if the warning about BP/SP is mentioned.

I don't have it installed now, but when I did use those versions of MSC, I
used alloca() regularly without any problems - at the highest optimisation
levels. I *did* have to avoid some optimisation, but only because of MSC
5.x and above's broken string intrinsics which had an unfortunate tendancy
to blow away register contents.


 > Under normal use there would always be at least 1 local variable
 > as a pointer to hold the return value from alloca()

Ahhh, NOW you're making sense. :)  Yes, you did have to have a stack frame
for alloca() to work correctly, and with MSC you can force this on
regardless, which I did as a matter of course. And yes, under all
circumstances that make any sense, the resulting buffer from alloca should
be assigned to an auto variable. The only danger from optimisation is that
your local variables are assigned to registers, but forcing the stack frame
regardless eliminates the problem. I'm not sure if you can do that with QC,
but I would have thought so. If nothing else works, then using _pascal
calling convention should do it.


 > BTW i'd assume any arguments passed to a function
 > using alloca() would force BP/SP to be setup anyway.

Except with the register calling convention  - _fastcall, I think they
called it). I'm not sure if MSC 6 has this, but MSC 7 certainly did.

Sorry I didn't remember any of this until you triggered the brain cells,
but it has been some time since I worked with MSC now.


Regards,
David

--- MaltEd/2 1.0.b6
* Origin: Unique Computing Pty Limited (3:632/348)
SEEN-BY: 50/99 620/243 623/630 632/103 107 348 360 633/371 634/388 396
SEEN-BY: 635/301 502 503 506 544 639/252 711/401 409 410 413 430 808 809 932
SEEN-BY: 711/934 712/515 713/888 714/906 800/1
@PATH: 632/348 635/503 50/99 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.