home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR2
/
DIGIPROG.ZIP
/
FCT0E.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-26
|
2KB
|
91 lines
#include <dos.h>
#include <stdio.h>
#define BSIZE 20*1024
main()
{
struct REGPACK sregs;
int y,x,numbytes,dx,ch,hexflg=0,hex,byte,numflg=0,num;
unsigned char buff[BSIZE];
union REGS regs;
/* init buffer for random data */
for(x=0; x<BSIZE; x++)
buff[x] = (x%0x5f)+0x20;
printf("\nEnter DX : ");
scanf("%d",&dx); while(kbhit()) getch();
printf("\nA)SCII or H)ex : ");
if(toupper(getch()) == 'H') hexflg=1;
printf("\nSpecify D)ata to send N)umber of bytes to send : ");
{
if(toupper(getch()) == 'N')
{
numflg++;
printf("\nEnter Number of Bytes to Send (in hex) : ");
scanf("%x", &num); while(kbhit()) getch();
printf("\nR)andom Data S)pecify Data : ");
if(toupper(getche()) == 'S')
{
printf("\nEnter Data Byte : ");
if(hexflg) { scanf("%x",&hex); byte = hex;}
else byte=getche();
for(x=0; x<num; x++)
buff[x] = byte;
}
}
else
{
if(hexflg)
printf("\nEnter string - Enter 0xFFFF to quit\n\n");
else
printf("\nEnter string - Hit <ESC> to quit\n\n");
num=0;
while(1)
{
if(hexflg)
{
scanf("%X",&byte);
if(byte==0xffff) break;
buff[num++] = byte;
}
else
{
buff[num] = getch();
if(buff[num]==0x1b) break;
if(buff[num] == 0xd)
{
buff[++num] = 0xa;
printf("\n");
num++;
}
else
printf("%c",buff[num++]);
}
}
}
}
/* write string */
sregs.r_ax = 0x0e00;
sregs.r_dx = dx;
sregs.r_cx = num;
sregs.r_es = FP_SEG(buff);
sregs.r_bx = FP_OFF(buff);
printf("\nCall - AH : %02X AL : %02X CX : %04X ES : BX = %04X:%04X ",
(sregs.r_ax&0xff00)>>8,(sregs.r_ax&0xff),sregs.r_cx,
sregs.r_es,sregs.r_bx);
intr(0x14,&sregs);
printf("\nReturn - AX : %04X DH : %02X ZF : %d ",sregs.r_ax,
(sregs.r_dx&0xff00)>>8,(sregs.r_flags&0x40)>>6);
}