[gforth] / gforth / Attic / main.c  

gforth: gforth/Attic/main.c

Diff for /gforth/Attic/main.c between version 1.1 and 1.2

version 1.1, Fri Feb 11 16:30:46 1994 UTC version 1.2, Thu May 5 15:46:48 1994 UTC
Line 14 
Line 14 
 #include <stdlib.h>  #include <stdlib.h>
 #include "forth.h"  #include "forth.h"
   
   #ifndef DEFAULTBIN
   #       define DEFAULTBIN ""
   #endif
   
 #ifdef DIRECT_THREADED  #ifdef DIRECT_THREADED
 #define CA(n)   (symbols[(n)])  #define CA(n)   (symbols[(n)])
 #else  #else
Line 32 
Line 36 
  * If the word is >=0, the address is within the image;   * If the word is >=0, the address is within the image;
  * addresses within the image are given relative to the start of the image.   * addresses within the image are given relative to the start of the image.
  * If the word is =-1, the address is NIL,   * If the word is =-1, the address is NIL,
  * If the word is between -2 and -4, it's a CFA (:, Create, Constant)   * If the word is between -2 and -5, it's a CFA (:, Create, Constant, User)
  * If the word is -5, it's a DOES> CFA   * If the word is -6, it's a DOES> CFA
  * If the word is <-5, it's a primitive   * If the word is -7, it's a DOES JUMP
    * If the word is <-7, it's a primitive
  */   */
   
 void relocate(int *image, char *bitstring, int size, Label symbols[])  void relocate(int *image, char *bitstring, int size, Label symbols[])
 {  {
         int i;          int i;
         static char bits[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};          static char bits[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
         Label DODOES=symbols[3];  
   #ifdef DEBUG
           printf("Dodoes-Adresse: %08x\n",(int)symbols[DODOES]);
   #endif
   
         for(i=0;i<size/sizeof(Cell);i++)          for(i=0;i<size/sizeof(Cell);i++)
                 if(bitstring[i >> 3] & bits[i & 7])                  if(bitstring[i >> 3] & bits[i & 7])
                         if(image[i]<0)                          if(image[i]<0)
                                 if(image[i]==-1)                                  switch(image[i])
                                         image[i]=0;  
                                 else if(image[i]>-5)  
                                         MAKE_CF(image+i,symbols[-image[i]-2]);  
                                 else if(image[i]==-5)  
                                 {                                  {
                                           case CF_NIL     :
                                                   image[i]=0; break;
                                           case CF(DOCOL)  :
                                           case CF(DOVAR)  :
                                           case CF(DOCON)  :
                                           case CF(DOUSER) :
                                                   MAKE_CF(image+i,symbols[CF(image[i])]); break;
                                           case CF(DODOES) :
                                         MAKE_DOES_CF(image+i,image[i+1]+((int)image));                                          MAKE_DOES_CF(image+i,image[i+1]+((int)image));
                                         i++; /* is this necessary? */                                                  i++; break; /* is this necessary? */
                                           case CF(DOESJUMP):
                                                   MAKE_DOES_HANDLER(image+i);
                                                   break;
                                           default:
                                                   image[i]=(Cell)CA(CF(image[i]));
                                 }                                  }
                                 else                                  else
                                         image[i]=(Cell)CA(-image[i]-2);  
                         else  
                                 image[i]+=(Cell)image;                                  image[i]+=(Cell)image;
 }  }
   
Line 120 
Line 135 
                         imagefile[strlen(imagefile)]='/';                          imagefile[strlen(imagefile)]='/';
         }          }
         else          else
                 imagefile[0]='\0';          {
                   strcpy(imagefile,DEFAULTBIN);
   
                   if(imagefile[0]!=0 && imagefile[strlen(imagefile)-1]!='/')
                           imagefile[strlen(imagefile)]='/';
           }
   
         if(argc>1 && argv[1][0]=='@')          if(argc>1 && argv[1][0]=='@')
         {          {


Generate output suitable for use with a patch program
Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help