Re: [Flashforth-devel] FF and C interfacing
Brought to you by:
oh2aun
|
From: Tovar <tv...@se...> - 2012-09-19 02:19:42
|
First, i got FlashForth to compile for a PIC18F2550 on MPLABX under Linux, as well as the current MPLAB under Windows. On MPLABX, it uses the C18 toolsuite, and with MPLAB under Windows, it currently uses the MPASM tools. Different toolsuites seem to be problematic on each IDE. It runs successfully on a homebrew card with a PICtail connector which was originally intended as a rotor controller as well as providing serial I/O and other access to hardward for USB only computers (such as Macintoshes). The current Debian Linux recognizes it and it shows up on /dev/ttyACM0 as USB serial device. I was very pleased that i could use the USB bootloader for this project. I'm looking at extending FlashForth to allow it to make network connections, initially via a WizNet evaluation board, but the code is being written to be device independent. So, for example, debugging of the networking code could be done using DDD under Linux rather than trying to figure this stuff out on a PIC without their fancy debugging tools (which might not even be as informative). An early non-FF version already executes the Microchip TCP client example code under Linux. The result, if it is useful, will probably be LGPL, as i don't share all of Stallman's philosophy. (Hint: we go way back.) I read the posting about some of what's need to make C and FF co-exist. Let's see if i'm on the right track and that this won't be too complex. For my purposes, i am assume that FF is largely in control of the computing environment, the operating system, as you would say. I want to have FF call C routines (probably via assembly hooks). I assume then that the assembly hooks would preserve non-volatile registers that FF uses, and load up ones that C expects to find. I assume that i only have limited use of the C library and need to be very careful what routines i used. (If this were to prove to be feasible, i would probaly make up a separate library which only contain FF-safe routines.) I also recognize that for the C routines to do certain things, it will have to call at least FF internals to do things like acquire and release blocks of memory, get time of day and probably do I/O operations as well. It would be nice if i could invoke Forth words from C, but that's less essential. Am i on the right track and how difficult might this be? -- Tovar (on the 'Net for nearly 40 years) |