On Apr 16, 2016, at 10:19 PM, Segher Boessenkool wrote:
On Sat, Apr 16, 2016 at 10:11:36PM -0400, Programmingkid wrote:
Mac OS 9 does alter the return stack in OpenBIOS. This is perceived to be unacceptable. The solution to this issue has been stated as implementing a second return stack. This stack would just be an array that implements push and pull calls.
In the bootinfo_load.c file, in the bootinfo_init_program() function is where the Mac OS 9 boot script is read into memory, into the bootscript variable. What I want to do is replace all >r and r> calls in the bootscript buffer with other words. Something like substitute>r and substitute_r>. These words would use a separate array to push and pop data from. I think this would work because Mac OS 9's boot script only uses the return stack for data storage. Does this sound like the right thing to do?
[ Please wrap your lines, this is unreadable. Thanks. ]
ok.
No; just implement a version of >R etc. that work in interpret mode. Like
: >r state @ IF postpone >r EXIT THEN ( and here, do the push to the simulated R stack ) ; IMMEDIATE
(And easier/cleaner/nicer if your system has separate compile and interpret behaviours for all words, or a separate compiler wordlist).
r is implemented in forth.c in c. So what do you think about this:
/* * >r ( x -- ) (R: -- x ) */
static void tor(void) { ucell tmp = POP(); #ifdef CONFIG_DEBUG_RSTACK printk(" >R: %x\n", tmp); #endif if (interpreting_bootscript == true) pushR2(tmp); else PUSHR(tmp); }
The new code would be this part: if (interpreting_bootscript == true) pushR2(tmp); else
pushR2() would push into another array that isn't the return stack.
interpreting_bootscript would be a global variable that is set in the bootinfo_init_program() function right before the call to feval() that runs the bootscript. This variable would be set to false right after the call to feval(). Basically this:
interpreting_bootscript = true; feval(bootscript); interpreting_bootscript = false;