Research website of Vyacheslav Gorchilin
All articles/PIC controllers
Assembler for 8-bit PIC controllers
Division two-byte binary number to four decimal places
In programming for pic controllers often need to display double byte binary number to four decimal seven-segment indicator. In this note it is proposed a fairly simple algorithm and its implementation in Assembly language. The code is 50 lines of code, uses 6 registers mandatory and 2 optional. In the first 4 compulsory register to put the result, which later can be output to the indicators, and the second 2 case, the initial binary number. 2 additional Ledger, you can use after you run this program on your own.
The maximum binary number should be less than 9999 — maximum number of digits. The program can count numbers up to a maximum of 65536, but in this case, the register num1000 will lie two-digit binary-coded decimal number that can be displayed only if add one more — the fifth level of the indicator.
Registers numFH,numFL recorded values are binary numbers high and low bytes respectively. Registers num1000..num1 will contain the execution result of the program. They will lie decimals — from older to younger respectively. Temporary registers temp,temp2 after this program, you can use at their discretion.