Index: soft/giet_vm/giet_libs/stdio.c
===================================================================
--- soft/giet_vm/giet_libs/stdio.c	(revision 558)
+++ soft/giet_vm/giet_libs/stdio.c	(revision 580)
@@ -142,4 +142,5 @@
 {
     int ret;                    // return value from the syscall 
+    enum TModifiers {NO_MOD, L_MOD, LL_MOD} modifiers;
 
 printf_text:
@@ -164,4 +165,5 @@
         {
             format++;
+            modifiers = NO_MOD;
             goto printf_arguments;
         }
@@ -173,15 +175,21 @@
 
     {
-        char buf[20];
+        char buf[30];
         char * pbuf;
         unsigned int len = 0;
         static const char HexaTab[] = "0123456789ABCDEF";
         unsigned int i;
+        
+        /* Ignored fields : width and precision */
+        for (; *format >= '0' && *format <= '9'; format++);
 
         switch (*format++) 
         {
+            case ('%'):
             case ('c'):             /* char conversion */
             {
                 int val = va_arg( *args, int );
+                if (modifiers != NO_MOD) goto return_error; //Modifiers have no meaning
+                
                 len = 1;
                 buf[0] = val;
@@ -189,7 +197,10 @@
                 break;
             }
-            case ('d'):             /* 32 bits decimal signed integer */
+            case ('d'):             /* decimal signed integer */
             {
                 int val = va_arg( *args, int );
+                
+                if (modifiers == LL_MOD) goto return_error; //64 bits not supported
+                
                 if (val < 0) 
                 {
@@ -211,37 +222,52 @@
                 break;
             }
-            case ('u'):             /* 32 bits decimal unsigned integer */
+            case ('u'):             /* decimal unsigned integer */
             {
-                unsigned int val = va_arg( *args, unsigned int );
-                for(i = 0; i < 10; i++) 
-                {
-                    buf[9 - i] = HexaTab[val % 10];
-                    if (!(val /= 10)) break;
-                }
-                len =  i + 1;
-                pbuf = &buf[9 - i];
-                break;
+                if (modifiers != LL_MOD) //32 bits integer
+                {
+                    unsigned int val = va_arg( *args, unsigned int );
+                    for(i = 0; i < 10; i++) 
+                    {
+                        buf[9 - i] = HexaTab[val % 10];
+                        if (!(val /= 10)) break;
+                    }
+                    len =  i + 1;
+                    pbuf = &buf[9 - i];
+                    break;
+                }
+                //64 bits : base 10 unsupported : continue to hexa
             }
-            case ('x'):             /* 32 bits hexadecimal integer */
+            case ('x'):
+            case ('X'):             /* hexadecimal integer */
             {
-                unsigned int val = va_arg( *args, unsigned int );
-                ret = sys_call(SYSCALL_TTY_WRITE,
-                               (unsigned int)"0x",
-                               2,
-                               channel,
-                               0);
-                if (ret != 2) goto return_error;       
-                for(i = 0; i < 8; i++) 
-                {
-                    buf[7 - i] = HexaTab[val % 16];
-                    if (!(val /= 16))  break;
-                }
-                len =  i + 1;
-                pbuf = &buf[7 - i];
-                break;
-            }
-            case ('l'):            /* 64 bits hexadecimal unsigned */
-            {
-                unsigned long long val = va_arg( *args, unsigned long long );
+                unsigned long long val;
+                int imax;
+                
+                if (modifiers == LL_MOD) //64 bits
+                {
+                    val = va_arg( *args, unsigned long long);
+                    
+                    if (*(format-1) == 'u' && (!(val & 0xFFFFFFFF00000000))) //if asked to print in base 10, can do only if it fits in 32 bits
+                    {
+                        unsigned int uintv = (unsigned int) val;
+                        
+                        for(i = 0; i < 10; i++) 
+                        {
+                            buf[9 - i] = HexaTab[uintv % 10];
+                            if (!(uintv /= 10)) break;
+                        }
+                        len =  i + 1;
+                        pbuf = &buf[9 - i];
+                        break;
+                    }
+                    
+                    imax = 16;
+                }
+                else //32 bits
+                {
+                    val = va_arg( *args, unsigned int);
+                    imax = 8;
+                }
+                
                 ret = sys_call(SYSCALL_TTY_WRITE,
                                (unsigned int)"0x",
@@ -250,11 +276,12 @@
                                0);
                 if (ret != 2) goto return_error;
-                for(i = 0; i < 16; i++) 
-                {
-                    buf[15 - i] = HexaTab[val % 16];
+                
+                for(i = 0; i < imax; i++) 
+                {
+                    buf[(imax-1) - i] = HexaTab[val % 16];
                     if (!(val /= 16))  break;
                 }
                 len =  i + 1;
-                pbuf = &buf[15 - i];
+                pbuf = &buf[(imax-1) - i];
                 break;
             }
@@ -262,4 +289,7 @@
             {
                 char* str = va_arg( *args, char* );
+                
+                if (modifiers != NO_MOD) goto return_error; //Modifiers have no meaning
+                
                 while (str[len]) 
                 {
@@ -269,4 +299,133 @@
                 break;
             }
+            case ('e'):
+            case ('f'):
+            case ('g'):             /* IEEE754 64 bits */
+            {
+                
+                double vald = va_arg( *args, double);
+                
+                unsigned long long
+                    val = *(unsigned long long*)&vald, //get ieee754 without conversion
+                    digits = val & 0xFFFFFFFFFFFFF;    //get mantissa
+                
+                unsigned int
+                    base = (unsigned int)((val & 0x7FF0000000000000) >> 52), //get exposant
+                    intp = (unsigned int)vald,         //get integer part of the float
+                    decp;
+                
+                int isvalue = 0;
+                
+                if (base == 0x7FF) //special value
+                {
+                    if (digits & 0xFFFFFFFFFFFFF)
+                    {
+                        /* Not a Number */
+                        buf[0] = 'N';
+                        buf[1] = 'a';
+                        buf[2] = 'N';
+                        len = 3;
+                        pbuf = buf;
+                    }
+                    else
+                    {
+                        /* inf */
+                        buf[0] = (val & 0x8000000000000000) ? '-' : '+';
+                        buf[1] = 'i';
+                        buf[2] = 'n';
+                        buf[3] = 'f';
+                        len = 4;
+                        pbuf = buf;
+                    }
+                    break;
+                }
+                
+                if (val & 0x8000000000000000)
+                {
+                    /* negative */
+                    ret = sys_call(SYSCALL_TTY_WRITE,
+                                (unsigned int)"-",
+                                1,
+                                channel,
+                                0);
+                    if (ret != 1) goto return_error;
+                    vald = vald * -1;
+                }
+                else
+                {
+                    /* positive */
+                    ret = sys_call(SYSCALL_TTY_WRITE,
+                                (unsigned int)"+",
+                                1,
+                                channel,
+                                0);
+                    if (ret != 1) goto return_error;
+                }
+                
+                if (vald > 0xFFFFFFFF)
+                {
+                    /* overflow */
+                    buf[0] = 'B';
+                    buf[1] = 'I';
+                    buf[2] = 'G';
+                    len = 3;
+                    pbuf = buf;
+                    break;
+                }
+                
+                vald -= (double)intp;
+                decp = (unsigned int)(vald * 100000000);
+                
+                for(i = 0; i < 10; i++) 
+                {
+                    if ((!isvalue) && (intp % 10)) isvalue = 1;
+                    buf[9 - i] = HexaTab[intp % 10];
+                    if (!(intp /= 10)) break;
+                }
+                pbuf = &buf[9 - i];
+                len = i+11;
+                buf[10] = '.';
+                
+                for(i = 0; i < 9; i++)
+                {
+                    if ((!isvalue) && (decp % 10)) isvalue = 1;
+                    buf[19 - i] = HexaTab[decp % 10];
+                    decp /= 10;
+                }
+                
+                if (!isvalue)
+                {
+                    if (vald != 0)
+                    {
+                        /* underflow */
+                        buf[0] = 'T';
+                        buf[1] = 'I';
+                        buf[2] = 'N';
+                        buf[3] = 'Y';
+                        len = 4;
+                        pbuf = buf;
+                    }
+                }
+
+                break;
+            }
+            case ('l'):
+                switch (modifiers)
+                {
+                    case NO_MOD:
+                        modifiers = L_MOD;
+                        goto printf_arguments;
+                    
+                    case L_MOD:
+                        modifiers = LL_MOD;
+                        goto printf_arguments;
+                    
+                    default:
+                        goto return_error;
+                }
+
+            /* Ignored fields : width and precision */
+            case ('.'): goto printf_arguments;
+                
             default:
                 goto return_error;
