home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / RiscOS / APP / DEVS / FORTH / BEETLE / BEETLE.ZIP / Beetle / beetle.c < prev    next >
C/C++ Source or Header  |  1997-04-22  |  1KB  |  65 lines

  1. /* BEETLE.C
  2.  
  3.     Vrsn  Date   Comment
  4.     ----|-------|---------------------------------------------------------------
  5.     0.00 02may95 Loads and runs bobj (the pForth image file).
  6.     0.01 05jun96 Takes the image file from the command line.
  7.  
  8.     Reuben Thomas
  9.  
  10.  
  11.     A minimal shell for Beetle which simply loads and runs the specified
  12.     object file (syntax: beetle <filename>).
  13.  
  14. */
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <ctype.h>
  20. #include "beetle.h"      /* main header */
  21.  
  22.  
  23. #ifdef unix              /* on a UNIX system, include keyboard hack */
  24. #include "noecho.c"
  25. #endif
  26.  
  27.  
  28. #define MEMSIZE 16384    /* size of Beetle's memory in cells */
  29.  
  30. int main(int argc, char *argv[])
  31. {
  32.     long i;
  33.     CELL *mem;
  34.     char *file = argv[1];
  35.     long adr = 16;
  36.     FILE *handle;
  37.     int ret;
  38.  
  39.     if (file == NULL) {
  40.         printf("Syntax: Beetle must be given a bForth image filename\n");
  41.         exit(1);
  42.     }
  43.  
  44.     mem = (CELL *)malloc(MEMSIZE * CELL_W);
  45.     for (i = 0; i < MEMSIZE; i++) mem[i] = 0;
  46.     init_beetle((BYTE *)mem, MEMSIZE, 16);
  47.     *THROW = 0;
  48.     A = 0;
  49.  
  50.     handle = fopen(file, "r");
  51.     load_object(handle, (CELL *)(M0 + adr));
  52.     fclose(handle);
  53.  
  54. #ifdef unix
  55.     init_keyb();
  56. #endif
  57.     ret = run();
  58. #ifdef unix
  59.     restore_keyb();
  60. #endif
  61.  
  62.  
  63.     return ret;
  64. }
  65.