[code=cpp]#include <iostream.h>
#include <stdio.h>
#include <conio.h>
#include "h.h"
void WriteToDataRegister()
{
cout<<"Write data to DATA register.\n"<<endl;
int b=0;
cout<<"Enter data: "<<endl;
cin>>b;
if (b<0||b>255)
cout<<"Error! You can take data only from diaposon 0-255."<<endl;
else
{
Out32(888, b);
cout<<"Write done.\n"<<endl;
}
cout<<"Press any key to back to Main menu..."<<endl;
getch();
system("cls");
}
void ReadDataRegister()
{
cout<<"Read data from DATA register.\n"<<endl;
int data;
data = Inp32(888);
cout<<"10: "<<data<<endl;
char number[20];
itoa(data,number,2);
cout<<" 2: "<<number<<endl;
cout<<"\nPress any key to back to Main menu..."<<endl;
getch();
system("cls");
}
void WriteToControlRegister()
{
cout<<"Write data to CONTROL register.\n"<<endl;
int b=0;
cout<<"Enter data: "<<endl;
cin>>b;
if (b<0||b>16)
cout<<"Error! You can take data only from diaposon 0-16."<<endl;
else
{
Out32(890, b);
cout<<"Write done.\n"<<endl;
}
cout<<"Press any key to back to Main menu..."<<endl;
getch();
system("cls");
}
void ReadControlRegister()
{
cout<<"Read data from CONTROL register.\n"<<endl;
int data;
data = Inp32(890);
cout<<"10: "<<data<<endl;
char number[20];
itoa(data,number,2);
cout<<" 2: "<<number<<endl;
cout<<"\nPress any key to back to Main menu..."<<endl;
getch();
system("cls");
}
void ReadStatusRegister()
{
cout<<"Read data from STATUS register.\n"<<endl;
int data;
data = Inp32(889);
cout<<"10: "<<data<<endl;
char number[20];
itoa(data,number,2);
cout<<" 2: "<<number<<endl;
cout<<"\nPress any key to back to Main menu..."<<endl;
getch();
system("cls");
}
void Menu()
{
cout<<"Select operation:"<<endl;
cout<<"1 - write data to DATA register."<<endl;
cout<<"2 - read data from DATA register"<<endl;
cout<<"3 - write data to CONTROL register."<<endl;
cout<<"4 - read data from CONTROL register"<<endl;
cout<<"5 - read data from STATUS register\n"<<endl;
cout<<"0 - exit"<<endl;
}
int main()
{
Menu();
while(1){
switch(getch())
{
case '1': system("cls");
WriteToDataRegister();
Menu();
break;
case '2': system("cls");
ReadDataRegister();
Menu();
break;
case '3': system("cls");
WriteToControlRegister();
Menu();
break;
case '4': system("cls");
ReadControlRegister();
Menu();
break;
case '5': system("cls");
ReadStatusRegister();
Menu();
break;
case '0': exit(0);
break;
}
}
return true;
}[/code]