| static UCell lsize=0; |
static UCell lsize=0; |
| int offset_image=0; |
int offset_image=0; |
| int die_on_signal=0; |
int die_on_signal=0; |
| |
#ifndef INCLUDE_IMAGE |
| static int clear_dictionary=0; |
static int clear_dictionary=0; |
| static int debug=0; |
|
| static size_t pagesize=0; |
static size_t pagesize=0; |
| |
#endif |
| |
static int debug=0; |
| char *progname; |
char *progname; |
| |
|
| /* image file format: |
/* image file format: |
| /* printf("relocating %x[%x]\n", image, size); */ |
/* printf("relocating %x[%x]\n", image, size); */ |
| |
|
| for(k=0; k<=steps; k++) |
for(k=0; k<=steps; k++) |
| for(j=0, bits=bitstring[k]; j<8; j++, i++, bits<<=1) { |
for(j=0, bits=bitstring[k]; j<RELINFOBITS; j++, i++, bits<<=1) { |
| /* fprintf(stderr,"relocate: image[%d]\n", i);*/ |
/* fprintf(stderr,"relocate: image[%d]\n", i);*/ |
| if(bits & 0x80) { |
if(bits & (1U << (RELINFOBITS-1))) { |
| /* fprintf(stderr,"relocate: image[%d]=%d\n", i, image[i]);*/ |
/* fprintf(stderr,"relocate: image[%d]=%d\n", i, image[i]);*/ |
| if((token=image[i])<0) |
if((token=image[i])<0) |
| switch(token) |
switch(token) |
| Cell *rp=(Cell *)(((ImageHeader *)image)->return_stack_base + rsize); |
Cell *rp=(Cell *)(((ImageHeader *)image)->return_stack_base + rsize); |
| Address lp=((ImageHeader *)image)->locals_stack_base + lsize; |
Address lp=((ImageHeader *)image)->locals_stack_base + lsize; |
| Xt *ip=(Xt *)(((ImageHeader *)image)->boot_entry); |
Xt *ip=(Xt *)(((ImageHeader *)image)->boot_entry); |
| |
#ifdef SYSSIGNALS |
| int throw_code; |
int throw_code; |
| |
#endif |
| |
|
| /* ensure that the cached elements (if any) are accessible */ |
/* ensure that the cached elements (if any) are accessible */ |
| IF_TOS(sp--); |
IF_TOS(sp--); |
| get_winsize(); |
get_winsize(); |
| #endif |
#endif |
| |
|
| |
#ifdef SYSSIGNALS |
| install_signal_handlers(); /* right place? */ |
install_signal_handlers(); /* right place? */ |
| |
|
| if ((throw_code=setjmp(throw_jmp_buf))) { |
if ((throw_code=setjmp(throw_jmp_buf))) { |
| return((int)engine(((ImageHeader *)image)->throw_entry,signal_data_stack+7, |
return((int)engine(((ImageHeader *)image)->throw_entry,signal_data_stack+7, |
| signal_return_stack+8,signal_fp_stack,0)); |
signal_return_stack+8,signal_fp_stack,0)); |
| } |
} |
| |
#endif |
| |
|
| return((int)engine(ip,sp,rp,fp,lp)); |
return((int)engine(ip,sp,rp,fp,lp)); |
| } |
} |
| int main(int argc, char **argv, char **env) |
int main(int argc, char **argv, char **env) |
| { |
{ |
| char *path = getenv("GFORTHPATH") ? : DEFAULTPATH; |
char *path = getenv("GFORTHPATH") ? : DEFAULTPATH; |
| |
#ifndef INCLUDE_IMAGE |
| char *imagename="gforth.fi"; |
char *imagename="gforth.fi"; |
| FILE *image_file; |
FILE *image_file; |
| #ifndef INCLUDE_IMAGE |
|
| Address image; |
Address image; |
| #endif |
#endif |
| int retvalue; |
int retvalue; |
| *p2='\0'; |
*p2='\0'; |
| retvalue = go_forth(image, 4, environ); |
retvalue = go_forth(image, 4, environ); |
| deprep_terminal(); |
deprep_terminal(); |
| exit(retvalue); |
|
| } |
} |
| |
return retvalue; |
| } |
} |