home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DIGIPROG.ZIP / FCT0E.C < prev    next >
C/C++ Source or Header  |  1993-08-26  |  2KB  |  91 lines

  1.  
  2. #include <dos.h>
  3. #include <stdio.h>
  4.  
  5. #define    BSIZE    20*1024
  6.  
  7. main()
  8. {
  9.  
  10.     struct REGPACK  sregs;
  11.  
  12.     int    y,x,numbytes,dx,ch,hexflg=0,hex,byte,numflg=0,num;
  13.     unsigned char    buff[BSIZE];
  14.     union REGS regs;
  15.  
  16.     /* init buffer for random data */
  17.  
  18.     for(x=0; x<BSIZE; x++)
  19.         buff[x] = (x%0x5f)+0x20;
  20.  
  21.     printf("\nEnter DX : ");
  22.     scanf("%d",&dx); while(kbhit()) getch();
  23.  
  24.     printf("\nA)SCII or H)ex : ");
  25.     if(toupper(getch()) == 'H') hexflg=1;
  26.  
  27.     printf("\nSpecify   D)ata to send    N)umber of bytes to send : ");
  28.     {
  29.         if(toupper(getch()) == 'N')
  30.         {
  31.             numflg++;
  32.             printf("\nEnter Number of Bytes to Send (in hex) : ");
  33.             scanf("%x", &num); while(kbhit()) getch();
  34.             printf("\nR)andom Data   S)pecify Data : ");
  35.             if(toupper(getche()) == 'S')
  36.             {
  37.                 printf("\nEnter Data Byte : ");
  38.                 if(hexflg) { scanf("%x",&hex); byte = hex;}
  39.                 else byte=getche();
  40.                 for(x=0; x<num; x++)
  41.                     buff[x] = byte;
  42.             }
  43.         }
  44.         else
  45.         {
  46.             if(hexflg)
  47.                 printf("\nEnter string - Enter 0xFFFF to quit\n\n");
  48.             else
  49.                 printf("\nEnter string - Hit <ESC> to quit\n\n");
  50.             num=0;
  51.  
  52.             while(1)
  53.             {
  54.                 if(hexflg)
  55.                 {
  56.                     scanf("%X",&byte);
  57.                     if(byte==0xffff) break;
  58.                     buff[num++] = byte;
  59.                 }
  60.                 else
  61.                 {
  62.                     buff[num] = getch();
  63.                     if(buff[num]==0x1b) break;
  64.                     if(buff[num] == 0xd)
  65.                     {
  66.                         buff[++num] = 0xa;
  67.                         printf("\n");
  68.                         num++;
  69.                     }
  70.                     else
  71.                         printf("%c",buff[num++]);
  72.                 }
  73.             }
  74.         }
  75.     }
  76.  
  77.  
  78.     /* write string */
  79.  
  80.     sregs.r_ax = 0x0e00;
  81.     sregs.r_dx = dx;
  82.     sregs.r_cx = num;
  83.     sregs.r_es = FP_SEG(buff);
  84.     sregs.r_bx = FP_OFF(buff);
  85.     printf("\nCall   - AH : %02X     AL : %02X   CX : %04X   ES : BX  =  %04X:%04X ",
  86.                        (sregs.r_ax&0xff00)>>8,(sregs.r_ax&0xff),sregs.r_cx,
  87.                        sregs.r_es,sregs.r_bx);
  88.     intr(0x14,&sregs);
  89.     printf("\nReturn - AX : %04X   DH : %02X   ZF : %d ",sregs.r_ax,
  90.             (sregs.r_dx&0xff00)>>8,(sregs.r_flags&0x40)>>6);
  91. }