Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!zephyr.ens.tek.com!tektronix!reed!reeder From: reeder@reed.UUCP (Doug Reeder) Newsgroups: comp.sys.apple Subject: Re: C on the apple Message-ID: <14063@reed.UUCP> Date: 5 Feb 90 09:50:37 GMT References: <6695@wpi.wpi.edu> <12647@cbnewsd.ATT.COM> <6761@wpi.wpi.edu> <10381@microsoft.UUCP> <12046@smoke.BRL.MIL> <17437@athertn.Atherton.COM> Reply-To: reeder@reed.UUCP (Doug Reeder) Organization: Institute of Knowledge, Jinx Lines: 36 In article <17437@athertn.Atherton.COM> paul@Atherton.COM (Paul Sander) writes: >Here's an idea I've been kicking around. How about using two stacks? Use the >6502 hardware stack for just the return addresses, and keep the activation >records in a separate stack just below the OS? Four bytes in zero page are >needed to keep the software stack pointer and frame pointer; addition and >subtraction on zero-page variables are fairly efficient, as are small memory >moves. Larger memory moves would be only slightly tricky if structures are >passed. Some optimization is also possible when copying parameters to the >stack if the things passed are allocated in the same order as they are to >appear on the stack. > >What do the compiler experts think? Is this plausible? Two stacks is entirely possible. GraFORTH was a Forth variant that was blindingly fast. Forth tends to be real fast because the program writer has to do a lot of work that other languages do for you. Forth uses the stack extensively. Graforth implements both a variable stack and a return stack separate from the 6502 stack, as zero page pointers to regions in main memory. One interesting thing to do when a subroutine is called is to have the subroutine always use the same memory space. You save the contents before you call, in dynamically allocated memory, and then restore them after the subroutine returns. All static variables have an absolute location in memory, which substantially reduces access time over indirectly referenced static variables. The chief disadvantage is that the variable space for ALL subroutines is always allocated, whether they are active or not. This is offset by the smaller code size. Making a subroutine call then has a substatial overhead, unless you have the compiler turn off varable saving for a non-recursive program. This is, in fact, the method used in Aardvaark Pascal. -- Doug Reeder USENET: ...!tektronix!reed!reeder from ARPA: tektronix!reed!reeder@berkeley.EDU BITNET: reeder@reed.BITNET the Little Mermaid on materialism: I just don't see how a world that makes such wonderful things ... could be bad!