home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DIGIPROG.ZIP / FCT1.C < prev    next >
C/C++ Source or Header  |  1993-04-01  |  1KB  |  61 lines

  1.  
  2. #include <dos.h>
  3. #include <stdio.h>
  4.  
  5. main()
  6. {
  7.  
  8.     struct REGPACK  sregs;
  9.     int    y,x,numbytes,dx,hexflg=0, numflg=0, hex, num=-1;
  10.     unsigned char    byte;
  11.     union REGS regs;
  12.  
  13.     printf("\nEnter DX : ");
  14.     scanf("%d",&dx); while(kbhit()) getch();
  15.  
  16.     printf("\nA)SCII or H)ex : ");
  17.     if(toupper(getch()) == 'H') hexflg=1;
  18.  
  19.     printf("\nSpecify   D)ata to send    N)umber of bytes to send : ");
  20.     {
  21.         if(toupper(getch()) == 'N')
  22.         {
  23.             numflg++;
  24.             printf("\nEnter Number of Bytes to Send : ");
  25.             scanf("%x", &num); while(kbhit()) getch();
  26.             printf("\nSpecify Byte to Send : ");
  27.             if(hexflg) scanf("%x",&hex);
  28.             else byte=getche();
  29.         }
  30.     }
  31.  
  32.  
  33.     if(hexflg && !numflg) printf("\nEnter 0xFFFF to Quit");
  34.     else if(!hexflg && !numflg) printf("\nEnter ESC to Quit ");
  35.     while(num--)
  36.     {
  37.         printf("\nEnter byte : ");
  38.         if(hexflg) goto hexcode;
  39.  
  40.         if(!numflg) byte = getch();
  41.         if(byte == 0x1b) break;
  42.         regs.h.ah = 0x01;
  43.         regs.h.al = byte;
  44.         regs.x.dx = dx;
  45.         printf("Send - %c ",byte);
  46.         int86(0x14,®s,®s);
  47.         printf("Return - AL : %c   AH : %02X",regs.h.al,regs.h.ah);
  48.         continue;
  49.  
  50.     hexcode:
  51.  
  52.         if(!numflg) scanf("%x",&hex);
  53.         if(hex == 0xFFFF) break;
  54.         regs.h.ah = 0x01;
  55.         regs.h.al = (char)hex;
  56.         regs.x.dx = dx;
  57.         printf("      Send - %02X ",(char)hex);
  58.         int86(0x14,®s,®s);
  59.         printf("Return - AL : %02x   AH : %02X",regs.h.al,regs.h.ah);
  60.     }
  61. }