j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
On Aug 20, 2010, at 6:00 AM, openbios-request@openbios.org wrote:
On Thu, Aug 19, 2010 at 4:52 PM, Programmingkid programmingkidx@gmail.com wrote:
I am trying to use the fword and feval functions in the file "kernel/forth.c". I know the header file for these functions are located in "include/libopenbios/bindings.h". I used this code to include the bindings.h file:
#include "libopenbios/bindings.h"
For some reason, I still see these errors:
Building OpenBIOS for x86 Building...error: ?HOSTCC host/kernel/bootstrap.o ?HOSTCC host/kernel/dict.o ?HOSTCC host/kernel/primitives.o ?HOSTCC host/kernel/stack.o ?HOSTCC forthstrap host/kernel/primitives.o: In function `setupLocalDictionary': /home/user/Development/openbios-devel/obj-x86/../kernel/forth.c:1035: undefined reference to `_fword' /home/user/Development/openbios-devel/obj-x86/../kernel/forth.c:1037: undefined reference to `_fword' /home/user/Development/openbios-devel/obj-x86/../kernel/forth.c:1044: undefined reference to `feval' /home/user/Development/openbios-devel/obj-x86/../kernel/forth.c:1045: undefined reference to `feval' host/kernel/primitives.o: In function `loadLocalVariable': /home/user/Development/openbios-devel/obj-x86/../kernel/forth.c:1072: undefined reference to `feval' collect2: ld returned 1 exit status make[1]: *** [forthstrap] Error 1 make[1]: Leaving directory `/home/user/Development/openbios-devel/obj-x86' make: *** [build] Error 1
This is a simple function someone could use as an example to be used in the file forth.c
static void test(void) { ? ? ? ?feval("banner"); }
Anyone know what I am doing wrong or how to solve this problem?
You are using the bootstrap compiler, which has only very limited set of basic Forth words defined and actually even some of those will not work during bootstrap time.
Full set of words like 'feval' is available when the library compiled by bootstrap compiler is loaded into non-bootstrap kernel. Your example should compile in arch/x86/openbios.c or arch/unix/unix.c.
Thanks for the help, but I still run into problems. I want to be able to use the functions from the forth interpreter. I tried adding my functions to primitives.c and bootstrap.c, but openbios won't compile.
Here are the functions I am trying to make available to the interpreter:
static void setupLocalDictionary(void) { int localWordListID, standardDictionaryID; #define NUMBER_OF_DICTIONARIES 2 char commandString[100]; fword("wordlist"); localWordListID = POP(); fword("get-order"); POP(); // removes the number of dictionaries standardDictionaryID = POP(); sprintf(commandString, "%d %d %d", standardDictionaryID, localWordListID, NUMBER_OF_DICTIONARIES); feval(commandString); feval("set-order"); }
// (addr len -- ) // variable static void loadLocalVariable(void) { int lengthOfVariableString, addressOfVariableString; char variableString[WIDTH], defineVariableCommandString[WIDTH]; int stackSize; #define NUMBER_OF_NEEDED_STACK_ITEMS 2 depth(); stackSize = POP(); if(stackSize < NUMBER_OF_NEEDED_STACK_ITEMS) { printk("\nSorry but loadLocalVarable needs stack in this format: (addr len -- )\n"); return; } lengthOfVariableString = POP(); addressOfVariableString = POP(); strncpy(variableString, (char *) addressOfVariableString, lengthOfVariableString); variableString[lengthOfVariableString] = '\0'; sprintf(defineVariableCommandString, "variable %s", variableString); feval(defineVariableCommandString); //printk("variable = %s\t", variableString); }
Any ideas as to where I can place them?
Attachments:
Programmingkid wrote:
Thanks for the help, but I still run into problems. I want to be able to use the functions from the forth interpreter. I tried adding my functions to primitives.c and bootstrap.c, but openbios won't compile.
Here are the functions I am trying to make available to the interpreter:
The outline of the functions looks reasonable, but in order to make this functionality work correctly I think it's going to have to be written in Forth. I suspect this will solve your compilation issue too.
HTH,
Mark.