On Thu, Jun 18, 1998 at 10:08:48AM -0500, [EMAIL PROTECTED] wrote: > > I need to set bits 0,1,4,5,6,7,11 for port 0x201. I have NO IDEA how > to calculate the bitmask! Obviously I need to learn this stuff so were > can I read up on this.
Read any book on analysis for undergraduates. The base number of the decimal system is 10. For example, 9378 can be read as 9*10^3 + 3*10^2 + 7*10^1 + 8*10^0 Note that 10^0=1, 10^1=10 and so on. For computers, the base 10 is not commonly used, better are 2, 8 and 16. The bits are really the digits of numbers with base 2. You want the number 100011110011 ^ ^ bit 11 bit 0 = 1*2^11+1*2^7+1*2^6+1*2^5+1*2^4+1*2^1+1*2^0 = 2048+127+64+32+16+2+1 = (left as an exercise for the reader) But it is easier, because you have to supply the bit mask as a hexadecimal number (0x????), so you can take four base2-digits and form a hexadecimal digit (base 16=2^4) (you have to start from the back) 0011 (base2) = 3 (base 10) = 3 (base 16) 1111 (base2) =15 (base 10) = f (base 16) 1000 (base2) = 8 (base 10) = 8 (base 16) So: 100011110011 (base2) = 0x08f3 Note that the hexadecimalsystem has by convention the digits 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f Marcus -- "Rhubarb is no Egyptian god." Debian GNU/Linux finger brinkmd@ Marcus Brinkmann http://www.debian.org master.debian.org [EMAIL PROTECTED] for public PGP Key http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/ PGP Key ID 36E7CD09 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]