Meta Compiling - IRTC

Meta Compiling, as its name implies, is the creation of something from itself. IRTC generates a Forth for the Remote Target from the Win32for Forth running on the PC.

When in the Host mode we Meta compile and create a Target image inside the PC. This image cannot be executed here as the code is for the PIC18F processor. However, the resultant code may be transferred, Downloaded, to the Target or to an programmer. In both cases the result is code generation that may be run in the Target.

When in the Remote mode we compile and create a Target image in the Host and in the Target. This is slower, as we have two things to do and one is via a serial link. But the result is instant code that may be executed.

Which approach is used depends on the position you are in with your application. To begin with you would experiment in the Remote mode until a section of code was written and debugged. Later you may compile and download the known code and then continue in the Remote mode to debug more.

What happens when we Meta Compile is quite simple, deceptively so. IRTC parses the ASCII text, from a file or the keyboard, and interprets the result. That is every space delimited word is searched for in the vocabularies shown in the right corner of the screen. If found the word is executed in the Host-PC. What happens as a result depends on the mode, Host or Remote, and on a variable STATE-T.

If we are in Host and STATE-T is false the word, if found, will execute in the Host-PC leaving its result on the Host stack if necessary. Any Target words will not be found in this state so will result in the message:

	Error: word is undefined

If we are in Remote and STATE-T is false, the word will execute in the Host-PC and, if a Target definition, its Code Field Address (CFA), will be sent to the Remote Target for execution there also. Any stack result will be left on the Remote Target stack.

If we are in Remote and STATE-T is true, the word executes in the Host-PC, and if a Target definition, its CFA is sent to the ISP to be placed in the next Target dictionary location. This is the Remote compile mode, set by encountering a : or ].

As can be seen the Host executes everything it finds in the Target vocabulary. If STATE-T is false the Remote Target executes the resulting CFA, if not it compiles it for execution later when the new definition is run.

Any definition found by IRTC that is not Target related just executes in the Host-PC and leaves its result there.

During Target CODE definitions all the Assembler words are executed. The object code generated is placed in the Target image in the PC and sent to the ISP for storage in the Remote Target, if in the Remote mode. The execution of these words by the Host causing this result

 

Contents