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

  1. /* RUNT.C
  2.  
  3.     Vrsn  Date   Comment
  4.     ----|-------|---------------------------------------------------------------
  5.     0.00 24mar95
  6.  
  7.     Reuben Thomas
  8.  
  9.  
  10.     Test that run works, and that the return value of the HALT instruction is
  11.     correctly returned.
  12.  
  13. */
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include "beetle.h"     /* main header */
  19. #include "btests.h"    /* Beetle tests header */
  20. #include "opcodes.h"    /* opcode enumeration */
  21. #include "debug.h"      /* debugging functions */
  22.  
  23.  
  24. int main(void)
  25. {
  26.     int i;
  27.     CELL ret;
  28.  
  29.     i = init_beetle((BYTE *)malloc(1024), 256, 16);
  30.     if (i != 0) {
  31.         printf("Error in RunT: init_beetle with valid parameters failed\n");
  32.         exit(1);
  33.     }
  34.     for (i = 0; i < 1024; i++) M0[i] = 0;
  35.  
  36.     here = (CELL *)(M0 + 52);
  37.     start_ass();
  38.     ass(O_LITERALI); ilit(37);
  39.     ass(O_HALT);
  40.     end_ass();
  41.  
  42.     NEXT;
  43.     ret = run();
  44.  
  45. #ifdef B_DEBUG
  46.     printf("Return value should be 37 and is %ld\n", ret);
  47. #endif
  48.     if (ret != 37) {
  49.         printf("Error in RunT: incorrect return value from run\n");
  50.         exit(1);
  51.     }
  52.  
  53. #ifdef B_DEBUG
  54.     printf("EP should now be 56\n");
  55. #endif
  56.     if (val_EP() != 60) {
  57.         printf("Error in RunT: EP = %ld\n", val_EP());
  58.         exit(1);
  59.     }
  60.  
  61.     printf("RunT ran OK\n");
  62.     return 0;
  63. }
  64.