Problem to divide two 16 bit numbers in 8051 series microcontrollers

AI Thread Summary
The discussion centers around coding a division algorithm for two 16-bit unsigned integers using the 8051 microcontroller, specifically the DS80C320-ECG. The original poster seeks clarification on the calculations involved in determining the quotient and remainder, expressing confusion about the necessity of these steps. Participants emphasize the importance of understanding long division principles, suggesting that the algorithm mirrors traditional long division, which can be adapted for binary operations. They recommend practicing the algorithm on paper before coding and advise against simply copying existing code to enhance learning. Additionally, resources such as the 8051 instruction set and educational videos by Ben Eater are suggested to aid understanding. Some participants also recommend starting with simpler programming tasks before tackling multi-byte division.
Stonestreecty
Messages
20
Reaction score
3
TL;DR Summary
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.
 
Technology news on Phys.org
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.
 
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.
 
I would also like to suggest that you try the videos produced by Ben Eater. He can teach you both the hardware and software side of computer operations, including micro code, software, interfacing, and even building a 6502 computer from scratch if you want to go that far.

https://www.youtube.com/user/eaterbc
 

Similar threads

Back
Top