Return

// Program     SWLTS.CPP     J. L. Errington Sept 1995

// Program reads value from switches, prints it to screen, and copies it to lights
// Requires:     BORLAND TURBO C++,
//                    PC with ADDA8 hardware card, Switches & Lights box

#include <dos.h>        //provides absolute address I/O functions
#include <stdio.h>
#include <conio.h>
// defines for absolute location of hardware devices on ADDA8 card
#define portbase 0x170              //Base address for ADDA8 hardware card
#define channel portbase+0       //Select analog input channel
#define ADC     portbase+1         //Analog input device
#define DAC1     portbase+2      //Analog output device
#define DAC2     portbase+3      //Analog output device
#define portA     portbase+0x0C //Port A register of 8255 PPI
#define portB     portbase+0x0D //Port B register of 8255 PPI
#define portC     portbase+0x0E //Port C register of 8255 PPI
#define portcontrol portbase+0x0F //Port control register of 8255 PPI

typedef unsigned char byte;
const byte config = 0x90; // set portA=inputs, portB=outputs, portC=outputs
                                    //all mode zero.

int main()
{
byte inbyte, outbyte;
outportb(portcontrol,config);    //initialise PPI
do
{
inbyte=inportb(portA);           //read value from switches on Port A of PPI
printf("value is $%2.2X \n",inbyte);
outbyte=inbyte;
outportb(portB,outbyte);        //send value to lights on Port B of PPI
}
while(inbyte);                        //as long as inbyte <> 0
return(0);
}