Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site uwvax.ARPA Path: utzoo!watmath!clyde!burl!ulysses!harpo!seismo!uwvax!anderson From: anderson@uwvax.ARPA Newsgroups: net.lang.forth Subject: Re: single-stepping in Forth Message-ID: <241@uwvax.ARPA> Date: Thu, 3-May-84 03:00:27 EDT Article-I.D.: uwvax.241 Posted: Thu May 3 03:00:27 1984 Date-Received: Fri, 4-May-84 02:39:12 EDT Organization: U of Wisconsin CS Dept Lines: 31 <> Single-stepping in Forth is not hard if you understand how the virtual machine works and how it is implemented. The key is to modify only the "inner interpreter", the piece of code that transfers control from one word to the next. All it does is, roughly speaking, MOV (IP)+,W JMP @(W) where IP and W are Forth virtual registers (IP is like a program counter). How this is implemented depends on your machine, but it is not complicated. You can implement single stepping by inserting a call to your debugging routine before or after the MOV. This assumes the routine is assembler, not Forth. If it's Forth things are messier because you don't want debugging routine single-stepping through itself. There is probably some way to do it involving a flag. The only other way of doing single stepping I can think of is to modify "docol" (the code pointed to by the CFA of colon definitions). However, this would not really be single stepping because it would not "break" at the start of "code" words. I used single-stepping while I was bringing up Forth on my 6809 system; the inner interpreter contained a couple of NOPs for this very purpose, and I replace them with a jump to the monitor. One thing, though, is that you have to do an awful lot of single stepping to get anywhere. Hope this helps -- David Anderson (anderson@uwvax (or wisc-rsch, as they call it now))