Understand how to divide two 16 bits number in 8051 microcontroller?

Electronics Computer Programming Q&A
Post Reply
Markkim
Posts: 9
Joined: Wed Apr 22, 2020 7:17 pm
Contact:

Understand how to divide two 16 bits number in 8051 microcontroller?

Post by Markkim » Mon May 17, 2021 1:36 am

Hello all,
I have this project to code in 8051 series, DS80C320-ECG (data source https://www.apogeeweb.net/productdetail ... g-juabqapc) showing: "Division of two 16 bit unsigned integers being in the internal memory, quotient and remainder should be stored".
I find a way to do it but there is a part of the program that i don't understand, I attach it.
I've noted which part i don't understand. By "don't understand", means that i'm not understanding why do we have to do all those calculations to find the quotient and the remainder.

Is there anyone have ideas of it? Or any advice?

dyarker
Posts: 1770
Joined: Fri Aug 22, 2003 1:01 am
Location: Izmir, Turkiye; from Rochester, NY
Contact:

Re: Understand how to divide two 16 bits number in 8051 microcontroller?

Post by dyarker » Mon May 17, 2021 10:15 pm

Or any advice?
Try the attach again? :grin:
Dale Y

User avatar
haklesup
Posts: 3081
Joined: Thu Aug 01, 2002 1:01 am
Location: San Jose CA
Contact:

Re: Understand how to divide two 16 bits number in 8051 microcontroller?

Post by haklesup » Thu May 27, 2021 1:08 pm

unsigned 16 bit means all 16 bits contribute to the value, in signed, the MSB indicates negative or positive.

your link seemed to lead to a datasheet page, I don't want to find the relevant section you are referring to but I suppose you are seeing a programatical (code) example of how to do binary math, perhaps it would be good to review how this is done manually with pencil and paper. to divide two long words, one calculates a result for each bit. so the program would include some kind of shift and loop instruction 16 times


In any case, binary long division is explained here
https://byjus.com/maths/binary-division/

Markkim
Posts: 9
Joined: Wed Apr 22, 2020 7:17 pm
Contact:

Re: Understand how to divide two 16 bits number in 8051 microcontroller?

Post by Markkim » Thu May 27, 2021 8:25 pm

Thank you for helping..
Can I extend that to binary. Do a trial subtract, record 1 if it stayed positive or revert and shift if trial was negative. Do that trial subtract 16 times when shift it to the right.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests