Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!mcf!mibte!gamma!thumper!sdh From: sdh@thumper.bellcore.com (Retief of the CDT) Newsgroups: comp.lang.forth Subject: Forth Implementation Question Keywords: Forth, 68000 Message-ID: <1715@thumper.bellcore.com> Date: 12 Sep 89 18:40:50 GMT Organization: Bell Communications Research Lines: 51 I need some help pronto. I'm writing a forth compiler for a 68000 machine, and am trying to implement it in a way that doesn't require access to the contiguous address space of the machine. In effect, when a word is compiled, it is shoved in a dynamically allocated block in a heap that is relocatable. All function calls would be rerouted through a dispatcher that would located the handle of the code block, lock it down and execute it. Upon return, it would unlock the block and return to the calling word. This poses a minor problem with variables, since a variable would push an address (in its own block) and return. The address will be incorrect if the variable's block is moved. This is easliy circumvented by putting all variables in a relocatable block acess from a register. This means that the address pushed on the stack for a variable is the displacement from the start of the variable block. I would like to include a word that given another word would assemble that word and words it calls into one small executable block, that no longer requires the dispatcher. Effectively, the interpretter is an incremental compiler, and can produce upon request a turnkey application that will only carry around the baggage of the functions it uses. The problem that this poses is that the language MUST have keywords. When a word is initially compiled, there is no way to grab a hold of WHERE the word is being compiled. This makes compile-time executable words an impossibility. I am writing this as an independent project at school. My advisor is not a FORTH guru, and thought it quite reasonable to allow the net to decide what action to take. The question comes down to: Should I implement my concept of a FORTH machine which takes away compile time executable objects (making the compiler not extensible), but making the the language "safe" in a machine where poking indiscriminantly into the address space could cause a segmentation fault. In addition, the word "forget" is safe in that it can be made to destroy only the word in question. It can produce turnkey apllications with minimal code over head. OR Should I simply implement FORTH as it stands, allowing the compiler extensions at the cost of dangerous memory practices. I realize that if I do the first it is no longer forth, but a warped hybrid. Please advise me on which approach I should take. If you need more info, ask me and I'll post anything I've left out. Steve Hawley sdh@flash.bellcore.com hawley@occs.oberlin.edu hawley@cwru.edu