The code above controls the display of a 7-segment LED, and the code for calculating values of dg[0] , dg[1], dg[2] is left to complete. I don't understand why even though dg[] is assigned already, we need to override or reassign the value again. Anyone can explain the working principle behind it? Thanks!
I believe that you're supposed to end up with a display that counts up, starting from the initial value 928 (or perhaps the initial value is just to provide quick verification that you're re-processing the value.)
It looks like there are two parts that have been left out (for you to fill in, presumably):
Come up with the dx table that translates between a BCD digit and its 7-segment representation.
Figure out how to extract the individual bcd digits dg from the binary integer cntr
It bothers me that cntr is not initialized (C specs say it will be initialized to zero. But an explicit initialization would be much better "style.") Perhaps you can initialize it to various values to make sure that all your digit extractions and conversions work correctly without having to watch for 1000 iterations.