home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / ansi / stdlib / system.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-20  |  1.2 KB  |  57 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <process.h>
  4. #include <go32.h>
  5. #include <dpmi.h>
  6.  
  7. void show(const char *m)
  8. {
  9.   __dpmi_regs r;
  10.   r.x.sp = r.x.ss = r.x.flags = 0;
  11.   r.x.ax = 0x5800;
  12.   __dpmi_simulate_real_mode_interrupt(0x21, &r);
  13. /*  printf("[%s: %02x] ", m, r.x.ax & 0xff);*/
  14. }
  15.  
  16. int
  17. main(int argc, char **argv)
  18. {
  19.   int rv;
  20.   int count = 10;
  21.   int base=0;
  22.   int nbase=_go32_info_block.linear_address_of_transfer_buffer;
  23.  
  24.   if (argc > 1)
  25.     count = atoi(argv[1]);
  26.   if (argc > 2)
  27.     base = atoi(argv[2]);
  28.  
  29.   printf("physical address = 0x%05x", nbase);
  30.   if (base)
  31.     printf(", using %05x bytes", nbase-base);
  32.   printf(", transfer buffer at 0x%05lx",
  33.      _go32_info_block.linear_address_of_transfer_buffer);
  34.     
  35.   putchar('\n');
  36.   show("before");
  37.  
  38.   if (--count)
  39.   {
  40. #if 1
  41.     char cline[50], nbline[50];
  42.     sprintf(cline, "%d", count);
  43.     sprintf(nbline, "%d", nbase);
  44.     rv = spawnl(P_WAIT, argv[0], argv[0], cline, nbline, 0);
  45.     if (rv == -1)
  46.       perror(argv[0]);
  47. #else
  48.     char cmd[100];
  49.     sprintf(cmd, "%s %d %d", argv[0], count, nbase);
  50.     rv = system(cmd);
  51. #endif
  52.     printf(" - returns %d\n", rv);
  53.   }
  54.   show("after");
  55.   return 0;
  56. }
  57.