From: noemail@basdxcqvbe.com   
      
   On Thu, 29 Jul 2021 22:11:00 -0700 (PDT)   
   "luser...@nospicedham.gmail.com"    
   wrote:   
      
      
   Sorry Frank, the first part of this may be a off-topic,   
   but I haven't been reading or posting to comp.lang.forth   
   in a while. So, I can understand if the OP posts here   
   with some Forth-ish assembly ...   
      
   > I wrote this machine code to trace the LIT word in   
   > my forth interpreter.   
      
   LIT is usually very simple and just stores an integer from   
   the interpreter's input stream into the current Forth word.   
      
      
   In C, my LIT primitive - the low-level function which goes   
   with the LIT dictionary entry - is:   
      
   void lit__(void)   
   {   
    push((cell_t)*ip);   
    ip++;   
   }   
      
   This dereferences/fetches what's at the Forth interpreter's   
   instruction pointer IP, stores that value on the parameter/data   
   stack, and then increments the IP.   
      
      
   I have LIT in the initial dictionary in C code (which I   
   use instead of assembly), because LIT is needed prior to   
   loading a high-level Forth dictionary. LIT is not a   
   standardized Forth word (subroutine).   
      
      
   You should be able to construct a LIT from your COMPILE   
   definition. E.g., just drop the , (comma) or equivalent   
   Forth word like COMPILE, from the end of the definition:   
      
   : COMPILE R> DUP CELL+ >R @ , ;   
   : LIT R> DUP CELL+ >R @ ;   
      
   For my personal Forth interpreter, the LIT is high-level   
   version of LIT equivalent to the low-level C code above.   
      
   I.e., the R> (r-from) captures the interpreter's saved IP,   
   DUPlicates the IP, increments one copy of the IP to skip   
   over the value, places the adjusted IP onto the return stack   
   via >R (to-r), fetches the value from the original IP onto   
   the parameter/data stack. That is the LIT value.   
      
   > Is it possible to tighten up this code? It's trying to   
   > print a 16bit signed integer (ignoring INT_MIN) left to   
   > right with no leading zeros.   
      
   Well, I really didn't look at the Forth-ish assembly,   
   but my suggestion to make your life easier would be   
   to print the decimal(?) "16bit signed integer" instead   
   in hexadecimal as a "16bit UN-signed integer".   
      
      
   --   
   ...   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|