#include #include main() { int i,j,k,l,a,b; unsigned char *i1,*i0,*j1,*j0,*k1,*k0,*l1,*l0; i0=&i; i1=i0+1; /* set i1 & i0 to the high & low bytes of i */ j0=&j; j1=j0+1; /* ditto for j0 & j1 */ k0=&k; k1=k0+1; /* set k1 & k0 to the high & low bytes of k */ l0=&l; l1=l0+1; /* ditto for l0 & l1 */ _clearscreen(_GCLEARSCREEN); printf(" Sum and Difference Program: hit any key to terminate. \n\n\n\r"); printf("The analog signals input to A/D 0 and A/D 1 are combined to produce \n\r"); printf("two output signals. D/A 0 outputs the sum of the 2 signals and \n\r"); printf("D/A 1 outputs the difference A/D 0 - A/D 1. \n\r"); loop: outp(0x301,0); /* select A/D ch. 0, set gain to 1 */ outp(0x302,0); /* start conversion */ outp(0x305,*k0); outp(0x306,*k1); /* output last value */ while(!(inp(0x300) & 0x40)); *i0=inp(0x303); *i1=inp(0x304); /* input voltage */ outp(0x301,1); /* select A/D ch. 1, set gain to 1 */ outp(0x302,0); /* start conversion */ outp(0x307,*l0); outp(0x308,*l1); /* output last value */ while(!(inp(0x300) & 0x40)); *j0=inp(0x303); *j1=inp(0x304); /* input voltage */ k=i+j; l=i-j; /* printf(" %d ",j); */ if(!kbhit())goto loop; } This listing of the file SUMDIF.C is included in case the file available in the INTRO directory is an older version that does not run correctly on faster PCs. Note the two 'while' statements before the 'inp()' lines and make changes to the source on the PC before executing the program.