//--------------------------------------------------------------- // EXAMPLE EX13.C : Demonstrate a FUNCTION call - III. // Parameters passed TO/FROM function, add(). // // 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(). int add(int a, int b); // Function definition or prototype. //--------------------------------------------------------------- void main() { int i, j, x; outportb(KEY_CON, 0x82); // Initialize 82C55A PPI with ports // KEY_PC and KEY_PA as OP ports and // port PB as an IP port. i = 1; j = 5; x = add(i,j); outportb(KEY_PC, x); outportb(KEY_PA, j); } //--------------------------------------------------------------- int add(int a, int b) { int j; j = a + b; return j; }