Super Fast binary to decimal routine

Pagina 2/2
1 |

Van retrocanada76

Hero (542)

afbeelding van retrocanada76

14-10-2011, 23:00

The unrolling gets the best performance cause you don't add 0's or make conditional jumps to avoid them. I don't think 593 bytes is a really bad routine Smile

We can do a semi-unrolled, that will take bits 0 - 6 (1 byte BCD) , 7 - 13 (2-byte BCD), and so on avoiding adding zeroes. That would be smaller. And we can remove all #00's from the LUT.

Van ARTRAG

Enlighted (6923)

afbeelding van ARTRAG

14-10-2011, 23:17

My two cent: if you use this code for printing score to the screen, you do not need to update it at full frame rate
You can keep trace of the score in ram in binary form and print it once out 20 frames

Van PingPong

Prophet (4093)

afbeelding van PingPong

15-10-2011, 12:41

My two cent: if you use this code for printing score to the screen, you do not need to update it at full frame rate
You can keep trace of the score in ram in binary form and print it once out 20 frames

effectively.... Smile

Van bore

Master (161)

afbeelding van bore

15-10-2011, 13:00

We can do a semi-unrolled, that will take bits 0 - 6 (1 byte BCD) , 7 - 13 (2-byte BCD), and so on avoiding adding zeroes. That would be smaller. And we can remove all #00's from the LUT.

Well, sort of, there are a few places where you add 0 but the result can be increased anyway becasue of a carry. In those cases you will still need to add 0 or do some other trick to add the carry to the result.
The current function also relies on the input data for looping. To loop sizes that are fractions of input bytes you will need to deal with a loop counter so I doubt that you can make it faster that way.
Perhaps you can use the table address in HL to count iterations.

Pagina 2/2
1 |