Binary to decimal canβt be that hard, right?
Video Statistics and Information
Channel: Ben Eater
Views: 763,895
Rating: undefined out of 5
Keywords:
Id: v3-a-zqKfgA
Channel Id: undefined
Length: 42min 26sec (2546 seconds)
Published: Sat Jun 27 2020
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Why is the upper remainder/subtraction 16-bit? If the highest a value there can possibly be is 17 after a shift the highest byte will always be 0, and thus the first
SBC #10
is sufficient to set the carry or not. Unless he is going for more generic division code straight off the bat.Oh shit he posted a new video? I must go.
FYI a lot of ways to solve this that are actually used are look up tables, it's simple to implement, much more efficient, relatively hard to bug up and the only disadvantage is that someone spent a lot of effort mapping all the digits/data to whatever is the right combination to put the numbers on the lsd.
Wait until it's a floating point binary, and praise Ryu ;)
For 6502 or Z80, a good way to perform binary-to-decimal conversion is to use ROL to extract bits from the binary data, and BCD addition to add a multi-word BCD value to itself.
Another alternative on systems without BCD might be to adopt a similar approach, but before each shift-left chain, add 28 to any byte whose upper bit is set. This will result in each byte holding a 100's value, except that some bytes will be left holding values 100-127. In a final cleanup stage, subtract 100 from each such byte and increment the byte above, and then split each byte into tens and ones.