#include <stdio.h>
#include <dos.h>
#include <time.h>
#define LSB 0
#define MSB 1
#define RXR 0
#define TXR 0
#define IER 1
#define IIR 2
#define LCR 3
#define MCR 4
#define LSR 5
#define MSR 6
#define Com1_base 0x3f8
#define uchar unsigned char
volatile uchar inputData;
volatile uchar onInput = 0x00;
volatile uchar onOutput = 0x00;
volatile uchar inputdata[256]; /*设设置接收缓冲区大小*/
volatile unsigned int count; /*中断接收的数据数目*/
int datacount;/*当前已发送数据条数*/
void interrupt (*OldVect)(); /*函数是用来获取中断处理程序的入口地址的*/
void interrupt SerialISR();
void InitCom()
{
uchar inttemp;
/*设置波特率什么的*/
outportb(Com1_base+LCR,0x80); /*使LCR的高位为1,以便读取其它寄存器*/
outportb(Com1_base+LSB,0x0c); /*除数锁存器(低8位)DLL*/
outportb(Com1_base+MSB,0x00); /*除数锁存器(高8位)DLH 产生2400波特率*/
outportb(Com1_base+LCR,0x03); /*8位数据,1位停止位,无校验*/
outportb(Com1_base+IER,0x01); /*接收采用中断方式*/
/*设置中断向量*/
OldVect = getvect(0x0c); /*函数是用来获取中断处理程序的入口地址的*/
disable();
inttemp = inportb(0x21)&0xef;
outportb(0x21,inttemp);
setvect(0x0c,SerialISR); /*设置SerialISR的中断入口地址为0X0C*/
enable();
}
void CloseCom()
{
disable();
outportb(Com1_base+IER,0x00); *禁止中断*/
outportb(Com1_base,0x00);
outportb(0x21,inportb(0x21)|~(0xef));
setvect(0x0c,OldVect);
}
void interrupt SerialISR()
{
/*串口中断服务代码*/
inputData = inportb(Com1_base+RXR);
onInput = 0x01;
inputdata[count]=inp
#include <dos.h>
#include <time.h>
#define LSB 0
#define MSB 1
#define RXR 0
#define TXR 0
#define IER 1
#define IIR 2
#define LCR 3
#define MCR 4
#define LSR 5
#define MSR 6
#define Com1_base 0x3f8
#define uchar unsigned char
volatile uchar inputData;
volatile uchar onInput = 0x00;
volatile uchar onOutput = 0x00;
volatile uchar inputdata[256]; /*设设置接收缓冲区大小*/
volatile unsigned int count; /*中断接收的数据数目*/
int datacount;/*当前已发送数据条数*/
void interrupt (*OldVect)(); /*函数是用来获取中断处理程序的入口地址的*/
void interrupt SerialISR();
void InitCom()
{
uchar inttemp;
/*设置波特率什么的*/
outportb(Com1_base+LCR,0x80); /*使LCR的高位为1,以便读取其它寄存器*/
outportb(Com1_base+LSB,0x0c); /*除数锁存器(低8位)DLL*/
outportb(Com1_base+MSB,0x00); /*除数锁存器(高8位)DLH 产生2400波特率*/
outportb(Com1_base+LCR,0x03); /*8位数据,1位停止位,无校验*/
outportb(Com1_base+IER,0x01); /*接收采用中断方式*/
/*设置中断向量*/
OldVect = getvect(0x0c); /*函数是用来获取中断处理程序的入口地址的*/
disable();
inttemp = inportb(0x21)&0xef;
outportb(0x21,inttemp);
setvect(0x0c,SerialISR); /*设置SerialISR的中断入口地址为0X0C*/
enable();
}
void CloseCom()
{
disable();
outportb(Com1_base+IER,0x00); *禁止中断*/
outportb(Com1_base,0x00);
outportb(0x21,inportb(0x21)|~(0xef));
setvect(0x0c,OldVect);
}
void interrupt SerialISR()
{
/*串口中断服务代码*/
inputData = inportb(Com1_base+RXR);
onInput = 0x01;
inputdata[count]=inp