Forth doesn't use CALL it uses JMP

Similar Threaded Interpretive Languages run an inner loop that does this pseudo code : (from Threaded Interpretive Languages: Their Design and Implementation by R. G. Loeliger)

COLON:
   PSH I -> RS
   WA -> I
   JMP NEXT
SEMI:
   POP RS -> I
NEXT: @I -> WA
   I += 2
RUN: @WA -> CA
   WA += 2
   CA -> PC

RS is the stack PC is the program counter, procedures JMP to NEXT or SEMI when they are done I is the indirection pointer, WA is the word address (the nomenclature for procedure) The 2s are there because this code assumes 16bit addressing, @ is indirection
CA is the call address

so DUP is a word defined as (it copies the item on the top of the stack back to the top of the stack
execute is a type marker, you can also have constant & colon

dup:
   execute
   POP SP -> A
   PUSH A -> SP
    PUSH A -> SP
  JMP NEXT


that's all very well but you then extend the assembler parts with new words made from the WAs (colon is the type marker for this) SEMI is where it JMPs to at the end

moddiv:
   colon
   divmod
   swop
   semi



I wrote a TIL in AVR assembler last summer but I've waiting to go on holiday this year so I can write some applications in it now I have a dev board :>




Reply via email to