I need to improve this program by using union and bit fields.I do not know to apply it in my program.
I hope you guys will be able to help me clear my doubt. Thanks!
#include <stdio.h>
#include <conio.h>
#include <dos.h>
// Channel1 "00001 0 [00]" :0x08 /0x48 /0x88 /0xc8
// Channel2 "00001 0 [01]" :0x09 /0x49 /0x89 /0xc9
// Channel3 "00001 0 [10]" :0x0A /0x4a /0x8a /0xca
// Channel4 "00001 0 [11]" :0x0b /0x4b /0x8b /0xcb
// Channel5 "00001 1 [00]" :0x0C /0x4c /0x8c /0xcc
// Channel6 "00001 1 [01]" :0x0D /0x4d /0x8d /0xcd
// Channel7 "00001 1 [10]" :0x0E /0x4e /0x8e /0xce
// Channel8 "00001 1 [11]" :0x0F /0x4f /0x8f /0xcf
.................................................. ........
This portion is the part which needs improvement.
if(x==1) //Select which board.
outportb(0x315, 0x08 + (r - 1)); //Select which channel.
if(x==2)
outportb(0x315, 0x48 + (r - 1));
if(x==3)
outportb(0x315, 0x88 + (r - 1));
if(x==4)
outportb(0x315, 0xc8 + (r - 1));
.................................................. ........



LinkBack URL
About LinkBacks


