It'd be much easier to accumulate 16 readings and divide by 16 (or 8 and divide by 8) because we can do it with some simple bit shifting. Accumulating more than 8 bits just means you need to use 16 bit arithmetic: eg: CBLOCK 0x?? Accum:2 ; A 2-byte value ENDC ; Add 8-bit value in W to 16-bit value in Accum addwf Accum,F ; Low 8 bits skpnc incf Accum+1,F ;Carry to high bits ; You should be able to find division code at www.piclist.com Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) ----- Original Message ----- From: Paul Chicofsky To: Sent: Wednesday, February 28, 2001 1:53 PM Subject: [PIC]division in assimbly > Hi every body, > I am trying to use the A/D of the PIC16F977. I have to collect 10 readings > from the A/D register ADRESH. Then add them and take the average of the > total which divide by 10. Fore example, if i get > 2.5 volts which is 0111 1111 in bits at ADRESH register because i only care > about the 8 high bits, (Right) > 1.25 volts which is 0011 1111 in bits, (Right) > . > . > . > so on > until 10 readings and then take the average. > > First, i have no clue how to implement the division > > Second,adding all that will be more than 8 bits. > > Can any body lead me to a program that do division in PIC?. Also, is it > possible to stor more than 8 bits in a register until the division come > along because after dividing the register the value will be reduced back to > 8 bits. It is just the matter of storing the 10 bits? > > Thank you > regards, > Paul > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.