Problem to divide two 16 bit numbers in 8051 series microcontrollers

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
7 replies · 4K views
Stonestreecty
Messages
20
Reaction score
3
TL;DR
Code in 8051 microcontroller Problem: How to understand "Division of two 16 bit unsigned integers being in the internal memory, quotient and remainder should be stored".
Hi all,
I have a project to code in 8051 series, DS80C320-ECG (data source as reference): "Division of two 16 bit unsigned integers being in the internal memory, quotient and remainder should be stored".
DS80C320-ECG Image.jpg

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? Thanks in advance.
 
Physics news on Phys.org
Baluncore said:
Is this assignment homework?
Do you understand long division?
https://en.wikipedia.org/wiki/Long_division
You can 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, as you shift it to the right.

I see no code attachment.
yep...the basic principle of binary division in a computer is similar to one of the "long division" methods using pencil and paper.
 

Attachments

You did not say if it was homework.

I think you should follow the algorithm on a sheet of paper in binary, then code it in assy. You will not learn much by copying existing code.

What do you not understand?
 
yep, it is a good learning experience as a beginner, I just want to make attempt at understanding the program.