# 8051 assembly question, 16 bit division asm for 80c51

1. ## 16 bit division asm for 80c51

hello forum!
i want to convert the data i am getting from adc ic into voltage .if the data reaches ff it means we have 5v and so on.so the formula should be (adc_data*5)/ff how to write the code in assembly i can do it in c and bascom but i need to do it in assembly please help

•

2. ## Re: 8051 assembly question

Create a look-up-table and use the MOVC A, @A+DPTR instruction ..
Here is an example:
http://www.8052.com/faqs/119923

Rgds,
IanP

•

3. ## Re: 8051 assembly question

u can calculate it, i guess ur using 8-bit adc with Vref+ as 5v and Vref- as 0v
so the step size is approx 20mv,
use two ram location say voltage_msb and voltage_lsb, where the voltage is stored in milli volts in BCD format. decrement the adc reading by 1 and add 20 to it keep repeating this loop till the adc reading becomes 0.
This method is much simpler are less tedious than making a lookup table

check :
http://www.dnatechindia.com/index.php/Code-Library/
for sample 8051 codes

•

4. ## 8051 assembly question

You can place the ADC_DATA in a ACC and the number (05h) in (B) register and use the multiply instruction (mul a,b) for multiplication and after the execution of this instruction you get the result in accumulator. and for division move the number (#0ffh) in (B) register and use (div a,b). if your result of multiplication is greater then 8 bits then your result will be placed in A and B registers and you should take care of it. you should handle the 16 bit division in 2 steps. like divide the number by 2,4 to bring it in the range of 8 bits. by shifting right and divide them in 2 or 4 steps.

--[[ ]]--