From: "A.Appleyard" To: DJGPP AT DELORIE DOT COM Date: Mon, 18 Mar 1996 10:18:09 GMT Subject: A notation for port reads and writes in djgpp C++ Message-ID: <5C570C5459@fs2.mt.umist.ac.uk> If I declare these C++ classes:- /*-----*/ class bport {public: unsigned short n; inline bport(unsigned short N){n=N;}; inline operator char(){return inportb(n);}; inline char operator=(char c){outportb(n,c); return c;};}; /*-----*/ class wport {public: unsigned int n; inline wport(unsigned int N){n=N;}; inline operator short(){return inportw(n);}; inline short operator=(short c){outportw(n,c); return c;};}; /*-----*/ class lport {public: unsigned int n; inline lport(unsigned int N){n=N;}; inline operator long(){return inportl(n);}; inline long operator=(long c){outportl(n,c); return c;};}; /*----- the value currently in port n decides what port n+1 means -----*/ class pport {public: unsigned short n; unsigned char i; inline pport(unsigned short N,unsigned short I){n=N; i=I;}; inline operator char(){outportb(n,i); return inportb(n+1);}; inline char operator=(char c){outportw(n,(i<<8)+c); return c;};}; /*-----*/ then I can represent ports by names as if they were ordinary variables, e.g.:- /*-----*/ char c; bport game_control_io(0x201); game_control_io=77; c=game_control_io; pport bit_plane_mask(0x3c4,2); bit_plane_mask=88; c=bit_plane_mask; /*-----*/ and inport and outport instructions explain themselves and don't need comments.