paracommr.cpp

来自「大学微型计算机接口技术实验源代码,直接就可以运行,包含了C++和asm代码,比较」· C++ 代码 · 共 56 行

CPP
56
字号

//*-------------------------------------------------------*/
//*    Cexp3r.cpp(双机并行通信接口实验-接收端程序)          */
//*    并行通信接收程序 Source File                        */
//*    Copyright (c) 2001 by HUST                         */
//*------------------------------------------------------ */

#include <dos.h>       //getvect(); setvect();
#include <conio.h>     //kbhit();
#include <stdlib.h>    //exit(0);
#include <stdio.h>     //printf();

void main()
{
	//int getvalue=0;
   clrscr();
	int invalue=0;
	int receivevalue=0;

    	printf("now receiving, please wait ! strike ESC to exit\n");
	
    //初始化8255   
	outportb(0x303,0x98);
	//置ACK=1
	outportb(0x303,0x07);

	//int i = 0;
	for(;;)
	{
		//有键按下
		if(kbhit())
		{
			if(getch()==0x1b)
			{
				return;
			}
		}
		//没有键按下
		else
		{
			invalue=inportb(0x302);
			//接受准备好
			if((invalue & 0x80) == 0)
			{
				//接受字符
				receivevalue=inportb(0x300);//A口接收数据
				printf("\n %c",receivevalue);
				outportb(0x303,0x06);//置ACK=0
				delay(100);
				outportb(0x303,0x07);//置ACk=1
				//printf("\n %c",receivevalue);
				//delay(200);
			}
		}
	}
}

⌨️ 快捷键说明

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