⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pc2pc.txt

📁 PC to PC connectivity
💻 TXT
字号:
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>

union REGS in ,out ;
unsigned char status = 0;
unsigned char string[50] = "Hello world !!";
int count = 0;

void recieve();
void transmit ();

void main()
{


clrscr();

	// COM1 INIT
	in.h.ah = 0x00;
	in.h.al = 0xA3;
	in.x.dx = 0x0000;
	int86 ( 0x14 , &in , &out );
	// INIT OVER

while (1)
{

	transmit();
	recieve();
}
}

void recieve ()
{
status = 0;
count = 0;
char data = 65;

printf("Comp1 >> ");
while ( data != '\0' )
{
	status = 0;
	while (!status)
	{
		in.h.ah = 0x03;
		in.x.dx = 0x0000;
		int86 ( 0x14 , &in , &out );
		status = out.h.ah;
		status = status & 0x01;
	}

	in.h.ah = 0x02;
	in.x.dx = 0x0000;
	int86 ( 0x14 , &in , &out );

	status = out.h.ah;
	status = status & 0x80;
	if ( status )
	{
		printf ("\nTimed out !!");
		getch();
		exit(0);
	}
	string[count] = out.h.al;
	data = string[count];
	count++;
}
printf("%s",string);

}


void transmit ( )
{
printf ("\nComp2 >> ");
scanf ("%s", string);
count = 0;

while ( count < strlen(string)+1 )
{
status = 0;
while ( status==0 )
{
	in.h.ah = 0x03;
	in.x.dx = 0x0000;
	int86 ( 0x14 , &in , &out );

	status = out.h.ah;
	status = status & 0x20;
}

	// SEND BYTE 'A'
	in.h.ah = 0x01;
	in.h.al = string[count];
	in.x.dx = 0x0000;
	int86 ( 0x14 , &in , &out );

	status = out.h.ah;
	status = status & 0x80;
	if ( status )
	{
		printf ("Connection timed out !!");
		getch();
		return;
	}

	//printf("\n\n%c" , string[count]);
	count++;
	//getch();
}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -