This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Bug in SitaraWare GrLib string printing

I tried to post this to sitaraware_support@list.ti.com, but my message was returned because I don't have permission to send messages to that list.

The software implementation of CLZ, NumLeadingZeros() in grlib/string.c, misses a special case: the case of being passed a zero. On zero, NumLeadingZeros() currently returns zero, which is incorrect. The ARM Architecture Reference Manual (DDI 0100I) specifies that CLZ (A4.1.13) should return 32 when the argument is zero. This function is used twice in grlib/string.c, and only when printing using an uncompressed font format. Only one font (fontfixed6x8) out of 153 that ship with GrLib is in the uncompressed format, but that's the font I was using.

diff --git a/grlib/string.c b/grlib/string.c
index 15863ed..d9d855a 100755
--- a/grlib/string.c
+++ b/grlib/string.c
@@ -79,6 +79,11 @@ unsigned char NumLeadingZeros(unsigned int x)
 {
        register unsigned char count = 0;//sizeof(x)*8;

+       if (x == 0)
+       {
+               return 32;
+       }
+
        while(x)
        {
                if(!(x & 0xFF000000))

 

Thanks,