koopman@a.gp.cs.cmu.edu (Philip Koopman) (03/05/91)
In article <1991Mar4.164425.25308@src.honeywell.com>, lowry@src.honeywell.com (Dave Lowry) writes: > Could someone explain to a FORTH neophyte the operation of CPUs that run > FORTH directly (RTX,SC32, etc.) I have been unable to find the stack > machines book mentioned on the net. Several people have gotten the book through inter-library loan (I'll e-mail you a citation upon request, or tell you how to order one from the publisher). > Are words like NEXT and COLON in the instruction set? > What does the memory image look like-- is it like a conventional FORTH > where machine code and word addresses are interspersed? In the name of brevity, this discussion contains sweeping generalities and simplifications. Forth-based stack machines use subroutine threaded code. That means that a reference to a colon definitions compiles up as a subroutine call instruction (just like CALL on an 80x86 or JSB on a VAX). Typically, the call instruction is implicit in the format of the call address (e.g., low bit of 0 means it's a call, and the high 15 bits are the call address). So, it is possible that a list of subroutine calls to colon definitions is just a sequence of addresses in memory (just like in many conventional Forths). The difference is that the hardware does the interpretation, not a threading loop. In other words, NEXT is entirely in hardware. In many machines, a call takes only one clock cycle. Semicolons compile into subroutine return instructions. In some machines, a single bit in an instruction denotes subroutine return, so this operation may be combined with other Forth primitives. Stack primitives are coded as native instructions (e.g., with the bottom bit 1 instead of 0). Two hardware stacks or stack buffers are provided so that subroutine calls get a hardware stack to save return addresses, and data operations get a hardware stack for operands. In many designs, it is possible to have simultaneous data and return stack operations. So, Forths for these stack machines tend to look and feel like a subroutine-threaded Forth on a conventional processor. They just run a whole lot faster (depending on clock speeds, RAM speeds, etc. etc.) Phil Koopman koopman@greyhound.ece.cmu.edu Internet 2525A Wexford Run Rd. (412) 935-6697 Wexford, PA 15090 *** this space for rent ***