//--------------------------------------------------------------- // EXAMPLE EX10.C : Demonstrate use of STRUCTURES. // // C.P. Diduch, Dec 1999. //--------------------------------------------------------------- #define KEY_PA 0x138 // 82C55A port addresses for PA, #define KEY_PB 0x13A // PB, #define KEY_PC 0x13C // PC and the #define KEY_CON 0x13E // Control Register. #include // conio.h contains prototypes for // inportb() and outportb(). //--------------------------------------------------------------- struct Grade { char test; char lab[5]; char final; }; struct Grade HARRY = {75,8,7,4,9,9,80}; // Initializes HARRY.test = 10, HARRY.labs[] = {8,7,4,9,9} // and HARRY.final = 30 void main() { int i; unsigned char total; outportb(KEY_CON, 0x82); // Initialize 82C55A PPI with ports // KEY_PC and KEY_PA as OP ports and // port PB as an IP port. total = (2*HARRY.test/10) + (7*HARRY.final/10); i = 0; for (i = 0; i < 5; i++) { total = total + (2*HARRY.lab[i]/10); } outport(KEY_PC, total); }