<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Thank you very much for all your help. I only wish there was documentation available on how to add words. Maybe I should make a tutorial and send it to the person in charge of the OpenBIOS website.</div><br><div><div>On Feb 24, 2010, at 6:00 AM, <a href="mailto:openbios-request@openbios.org">openbios-request@openbios.org</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Message: 5<br>Date: Wed, 24 Feb 2010 10:13:23 +0000<br>From: Mark Cave-Ayland <<a href="mailto:mark.cave-ayland@siriusit.co.uk">mark.cave-ayland@siriusit.co.uk</a>><br>To: The OpenBIOS Mailinglist <<a href="mailto:openbios@openbios.org">openbios@openbios.org</a>><br>Subject: Re: [OpenBIOS] Help with local variables<br>Message-ID: <<a href="mailto:4B84FBC3.4040108@siriusit.co.uk">4B84FBC3.4040108@siriusit.co.uk</a>><br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>G 3 wrote:<br><br><blockquote type="cite">Hi, I am working on implementing local variable support in OpenBIOS. I <br></blockquote><blockquote type="cite">have done a lot of research on the issue, but there are a few issues I <br></blockquote><blockquote type="cite">still need help resolving. <br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-Does Openbios context switch when a word is called? This is when all <br></blockquote><blockquote type="cite">the registers are saved into a stack frame, so the currently executing <br></blockquote><blockquote type="cite">word can use them.<br></blockquote><br>I think you are looking too low a level here - all of this is handled <br>automatically by the Forth engine.<br><br><blockquote type="cite">-Could someone give me a tutorial on how to add c functions to forth and <br></blockquote><blockquote type="cite">make them accessible to the interpreter. I want to be able to add words <br></blockquote><blockquote type="cite">to the dictionary and be able to use them from the command line.<br></blockquote><br>The easiest way to look at this is to look at one of the existing <br>primitive words such as DOCOL. But in short:<br><br>- Add the new word to the end of the wordnames array in kernel/bootstrap.c<br><br>- Add the C function name to the end of the words array in <br>kernel/primitives.c<br><br>- Add the C function to kernel/internal.c<br><br><blockquote type="cite">- Would anyone know which register on the PowerPC would be good for <br></blockquote><blockquote type="cite">using as a stack pointer for a new local variable stack? I think r13 is <br></blockquote><blockquote type="cite">free and a possible candidate. <br></blockquote><br>Again, you're looking at too low a level here. What I believe you need <br>to do is create a word that adds a new dictionary to the search list at <br>the start of the function, much in the same way that a package instance <br>does.<br><br><br>HTH,<br><br>Mark.<br><br>-- <br>Mark Cave-Ayland - Senior Technical Architect<br>PostgreSQL - PostGIS<br>Sirius Corporation plc - control through freedom<br><a href="http://www.siriusit.co.uk/">http://www.siriusit.co.uk</a><br>t: +44 870 608 0063<br><br>Sirius Labs: <a href="http://www.siriusit.co.uk/labs">http://www.siriusit.co.uk/labs</a></span></blockquote><div><br></div></div></body></html>