Index: init/Makefile
===================================================================
--- init/Makefile	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ init/Makefile	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -32,4 +32,5 @@
 LIBC_PREFIX = ../libc
 LIBIPC_PREFIX = ../libipc
+SOFTINT_PREFIX = ../softint
 include $(LIBC_PREFIX)/Makefile.toolchain
 
Index: init/init.c
===================================================================
--- init/init.c	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ init/init.c	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -47,9 +47,13 @@
 	printf("Simple text.\n");
 	printf("Now insert '%s' string.\n","this");
-	printf("We are brave enought to print numbers like %%d = '%d'\n", 0x123456);
-	printf("And now... '%b' byte! '%w' word! '%W' Word! \n", 0x12, 0x1234, 0x1234);
-	printf("'%Q' Q! Another '%q' q! \n", 0x1234567887654321ll, 0x1234567887654321ll);
-	printf("'%Q' with 64bit value and '%p' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 );
-	printf("'%Q' 64bit, '%p' 32bit, '%b' 8bit, '%w' 16bit, '%Q' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, 0x1234567887654321ull, "Lovely string" );
+	printf("Signed formats on uns. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", 321, 321, 321, 321);
+	printf("Signed formats on sig. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", -321, -321, -321, -321);
+	printf("Signed with different sized: '%hhd', '%hd', '%d', '%ld', %lld;\n", -3, -32, -321, -32101l, -3210123ll);
+	printf("And now... '%hhd' byte! '%hd' word! '%d' int! \n", 11, 11111, 1111111111);
+	printf("Different bases: %#hx, %#hu, %#ho and %#hb\n", 123, 123, 123, 123);
+	printf("Different bases signed: %#hx, %#hu, %#ho and %#hb\n", -123, -123, -123, -123);
+	printf("'%llX' llX! Another '%llx' llx! \n", 0x1234567887654321ll, 0x1234567887654321ll);
+	printf("'%llX' with 64bit value and '%x' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 );
+	printf("'%llx' 64bit, '%x' 32bit, '%hhx' 8bit, '%hx' 16bit, '%llX' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, 0x1234567887654321ull, "Lovely string" );
 	
 	printf("Thats all, folks!\n");
@@ -113,5 +117,5 @@
 static void got_answer(void *private, int retval, ipc_data_t *data)
 {
-	printf("Retval: %d...%s...%X, %X\n", retval, private,
+	printf("Retval: %d...%s...%zX, %zX\n", retval, private,
 	       IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
 }
@@ -157,5 +161,5 @@
 	printf("Asking 0 to connect to me...\n");
 	res = ipc_connect_to_me(0, 1, 2, &taskid);
-	printf("Result: %d - taskid: %Q\n", res, taskid);
+	printf("Result: %d - taskid: %llu\n", res, taskid);
 	for (i=0; i < 100; i++) {
 		printf("----------------\n");
@@ -179,5 +183,5 @@
 	printf("pinging.\n");
 	res = ipc_call_sync(res, NS_PING, 0xbeef,&result);
-	printf("Retval: %d - received: %P\n", res, result);
+	printf("Retval: %d - received: %zd\n", res, result);
 	
 }
Index: libc/Makefile
===================================================================
--- libc/Makefile	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ libc/Makefile	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -31,4 +31,5 @@
 
 LIBC_PREFIX = .
+SOFTINT_PREFIX = ../softint
 
 ## Setup toolchain
@@ -39,4 +40,5 @@
 ## Sources
 #
+
 
 GENERIC_SOURCES = \
Index: libc/Makefile.toolchain
===================================================================
--- libc/Makefile.toolchain	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ libc/Makefile.toolchain	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -29,6 +29,7 @@
 DEFS = -DARCH=$(ARCH)
 CFLAGS = -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -I$(LIBC_PREFIX)/include -I$(LIBC_PREFIX)/arch/$(ARCH)/include
-LFLAGS = -M
+LFLAGS = -M -N $(SOFTINT_PREFIX)/softint.a
 AFLAGS =
+
 
 ## Setup platform configuration
Index: libc/generic/io/print.c
===================================================================
--- libc/generic/io/print.c	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ libc/generic/io/print.c	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -33,41 +33,30 @@
 #include <stdarg.h>
 
-#define __PRINTF_FLAG_PREFIX 0x00000001
-#define __PRINTF_FLAG_SIGNED 0x00000002
-
-static char digits[] = "0123456789abcdef"; 	/**< Hexadecimal characters */
-
-/** Print hexadecimal digits
- *
- * Print fixed count of hexadecimal digits from
- * the number num. The digits are printed in
- * natural left-to-right order starting with
- * the width-th digit.
- *
- * @param num   Number containing digits.
- * @param width Count of digits to print.
- *
- */
-static int print_fixed_hex(const uint64_t num, const int width, uint64_t flags)
-{
-	int i;
-	char buf[18]; /* 16 bytes for number + 2 for optionaly prefix */
-	char *bptr;
-	
-	bptr = buf;
-	
-	if (flags & __PRINTF_FLAG_PREFIX) {
-		buf[0] = '0';
-		buf[1] = 'x';
-		bptr += 2;
-	}
-
-	for (i = width*8 - 4; i >= 0; i -= 4)
-		*bptr++ = digits[(num>>i) & 0xf];
-	*bptr = '\0';
-	
-	return putstr(buf);	
-}
-
+#define __PRINTF_FLAG_PREFIX		0x00000001	/* show prefixes 0x or 0*/
+#define __PRINTF_FLAG_SIGNED		0x00000002	/* signed / unsigned number */
+#define __PRINTF_FLAG_ZEROPADDED	0x00000004	/* print leading zeroes */
+#define __PRINTF_FLAG_LEFTALIGNED	0x00000010	/* align to left */
+#define __PRINTF_FLAG_SHOWPLUS		0x00000020	/* always show + sign */
+#define __PRINTF_FLAG_SPACESIGN		0x00000040	/* print space instead of plus */
+#define __PRINTF_FLAG_BIGCHARS		0x00000080	/* show big characters */
+#define __PRINTF_FLAG_NEGATIVE		0x00000100	/* number has - sign */
+
+#define PRINT_NUMBER_BUFFER_SIZE	(64+5)		/* Buffer big enought for 64 bit number
+							 * printed in base 2, sign, prefix and
+							 * 0 to terminate string.. (last one is only for better testing 
+							 * end of buffer by zero-filling subroutine)
+							 */
+typedef enum {
+	PrintfQualifierByte = 0,
+	PrintfQualifierShort,
+	PrintfQualifierInt,
+	PrintfQualifierLong,
+	PrintfQualifierLongLong,
+	PrintfQualifierSizeT,
+	PrintfQualifierPointer
+} qualifier_t;
+
+static char digits_small[] = "0123456789abcdef"; 	/* Small hexadecimal characters */
+static char digits_big[] = "0123456789ABCDEF"; 	/* Big hexadecimal characters */
 
 /** Print number in given base
@@ -77,23 +66,76 @@
  *
  * @param num  Number to print.
+ * @param size not used, in future releases will be replaced with precision and width params
  * @param base Base to print the number in (should
  *             be in range 2 .. 16).
+ * @param flags output modifiers
+ * @return number of written characters or EOF
  *
  */
-static int print_number(const unsigned long num, const unsigned int base, uint64_t flags)
+static int print_number(uint64_t num, size_t size, int base , uint64_t flags)
 {
-	int val = num;
-	char d[sizeof(unsigned long)*8+1];	/* this is good enough even for base == 2 */
-	int i = sizeof(unsigned long)*8-1;
-	
-	/* FIXME: if signed, print sign */
-	
-	do {
-		d[i--] = digits[val % base];
-	} while (val /= base);
-	
-	d[sizeof(unsigned long)*8] = 0;	
-
-	return putstr(&d[i + 1]);
+	/* FIXME: This is only first version.
+	 * Printf does not have support for specification of size 
+	 * and precision, so this function writes with parameters defined by
+	 * their type size.
+	 */
+	char *digits = digits_small;
+	char d[PRINT_NUMBER_BUFFER_SIZE];	/* this is good enough even for base == 2, prefix and sign */
+	char *ptr = &d[PRINT_NUMBER_BUFFER_SIZE - 1];
+	
+	if (flags & __PRINTF_FLAG_BIGCHARS) 
+		digits = digits_big;	
+	
+	*ptr-- = 0; /* Put zero at end of string */
+
+	if (num == 0) {
+		*ptr-- = '0';
+	} else {
+		do {
+			*ptr-- = digits[num % base];
+		} while (num /= base);
+	}
+	if (flags & __PRINTF_FLAG_PREFIX) { /*FIXME*/
+		switch(base) {
+			case 2:	/* Binary formating is not standard, but usefull */
+				*ptr = 'b';
+				if (flags & __PRINTF_FLAG_BIGCHARS) *ptr = 'B';
+				ptr--;
+				*ptr-- = '0';
+				break;
+			case 8:
+				*ptr-- = 'o';
+				break;
+			case 16:
+				*ptr = 'x';
+				if (flags & __PRINTF_FLAG_BIGCHARS) *ptr = 'X';
+				ptr--;
+				*ptr-- = '0';
+				break;
+		}
+	}
+	
+	if (flags & __PRINTF_FLAG_SIGNED) {
+		if (flags & __PRINTF_FLAG_NEGATIVE) {
+			*ptr-- = '-';
+		} else if (flags & __PRINTF_FLAG_SHOWPLUS) {
+				*ptr-- = '+';
+			} else if (flags & __PRINTF_FLAG_SPACESIGN) {
+					*ptr-- = ' ';
+				}
+	}
+
+	/* Print leading zeroes */
+
+	if (flags & __PRINTF_FLAG_LEFTALIGNED) {
+		flags &= ~__PRINTF_FLAG_ZEROPADDED;
+	}
+	if (flags & __PRINTF_FLAG_ZEROPADDED) {
+	       	while (ptr != d ) {
+			*ptr-- = '0';
+		}
+	}
+	
+	return putstr(++ptr);
 }
 
@@ -157,9 +199,14 @@
 int printf(const char *fmt, ...)
 {
-	int i = 0, j = 0;
-	int counter, retval;
+	int i = 0, j = 0; /* i is index of currently processed char from fmt, j is index to the first not printed nonformating character */
+	int end;
+	int counter; /* counter of printed characters */
+	int retval; /* used to store return values from called functions */
 	va_list ap;
-	char c;	
-
+	char c;
+	qualifier_t qualifier;	/* type of argument */
+	int base;	/* base in which will be parameter (numbers only) printed */
+	uint64_t number; /* argument value */
+	size_t	size; /* byte size of integer parameter */
 	uint64_t flags;
 	
@@ -177,19 +224,51 @@
 				counter += retval;
 			}
-			
-			j = ++i;
-			
+		
+			j = i;
 			/* parse modifiers */
 			flags = 0;
-			/*switch (c = fmt[i]) {
-				case '-':	
+			end = 0;
+			
+			do {
+				++i;
+				switch (c = fmt[i]) {
+					case '#': flags |= __PRINTF_FLAG_PREFIX; break;
+					case '-': flags |= __PRINTF_FLAG_LEFTALIGNED; break;
+					case '+': flags |= __PRINTF_FLAG_SHOWPLUS; break;
+					case ' ': flags |= __PRINTF_FLAG_SPACESIGN; break;
+					case '0': flags |= __PRINTF_FLAG_ZEROPADDED; break;
+					default: end = 1;
+				};	
+				
+			} while (end == 0);	
+			/* TODO: width & '*' operator */
+			/* TODO: precision and '*' operator */	
+
+			switch (fmt[i++]) {
+				case 'h':	/* char or short */
+					qualifier = PrintfQualifierShort;
+					if (fmt[i] == 'h') {
+						i++;
+						qualifier = PrintfQualifierByte;
+					}
+					break;
+				case 'l':	/* long or long long*/
+					qualifier = PrintfQualifierLong;
+					if (fmt[i] == 'l') {
+						i++;
+						qualifier = PrintfQualifierLongLong;
+					}
+					break;
+				case 'z':	/* size_t */
+					qualifier = PrintfQualifierSizeT;
+					break;
+				default:
+					qualifier = PrintfQualifierInt; /* default type */
+					--i;
 			}	
-			*/
+			
+			base = 10;
+
 			switch (c = fmt[i]) {
-
-				/* percentile itself */
-				case '%': 
-					--j;	/* soon will be incremented back */
-					break;
 
 				/*
@@ -202,5 +281,6 @@
 					
 					counter += retval;
-					break;
+					j = i + 1; 
+					goto next_char;
 				case 'c':
 					c = va_arg(ap, unsigned long);
@@ -210,83 +290,108 @@
 					
 					counter += retval;
-					break;
-
-				/*
-				* Hexadecimal conversions with fixed width.
+					j = i + 1;
+					goto next_char;
+
+				/* 
+				 * Integer values
 				*/
-				case 'P':
-				       	flags |= __PRINTF_FLAG_PREFIX;
+				case 'P': /* pointer */
+				       	flags |= __PRINTF_FLAG_BIGCHARS;
 				case 'p':
-	    				if ((retval = print_fixed_hex(va_arg(ap, unsigned long), sizeof(unsigned long), flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-					break;
-				case 'Q':
-				       	flags |= __PRINTF_FLAG_PREFIX;
-				case 'q':
-	    				if ((retval = print_fixed_hex(va_arg(ap, uint64_t), sizeof(uint64_t), flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-					break;
-				case 'L': 
-				       	flags |= __PRINTF_FLAG_PREFIX;
-				case 'l':
-	    				if ((retval = print_fixed_hex(va_arg(ap, unsigned long), sizeof(uint32_t), flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-			   		break; 
-				case 'W':
-				       	flags |= __PRINTF_FLAG_PREFIX;
-				case 'w':
-	    				if ((retval = print_fixed_hex(va_arg(ap, unsigned long), sizeof(uint16_t), flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-					break;
-				case 'B':
-				       	flags |= __PRINTF_FLAG_PREFIX;
-				case 'b':
-	    				if ((retval = print_fixed_hex(va_arg(ap, unsigned long), sizeof(uint8_t), flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-					break;
-				/*
-				* Decimal and hexadecimal conversions.
-				*/
+					flags |= __PRINTF_FLAG_PREFIX;
+					base = 16;
+					qualifier = PrintfQualifierPointer;
+					break;	
+				case 'b': 
+					base = 2;
+					break;
+				case 'o':
+					base = 8;
+					break;
 				case 'd':
 				case 'i':
-				       	flags |= __PRINTF_FLAG_SIGNED;
-	    				if ((retval = print_number(va_arg(ap,unsigned long), 10, flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-			   		break; 
+					flags |= __PRINTF_FLAG_SIGNED;  
+				case 'u':
+					break;
 				case 'X':
-				       	flags |= __PRINTF_FLAG_PREFIX;
+					flags |= __PRINTF_FLAG_BIGCHARS;
 				case 'x':
-	    				if ((retval = print_number(va_arg(ap, unsigned long), 16, flags)) == EOF ) {
-						return -counter;
-					};
-
-					counter += retval;
-			   		break; 
+					base = 16;
+					break;
+				/* percentile itself */
+				case '%': 
+					j = i;
+					goto next_char;
 				/*
 				* Bad formatting.
 				*/
 				default:
+					/* Unknown format
+					 *  now, the j is index of '%' so we will
+					 * print whole bad format sequence
+					 */
+					goto next_char;		
+			}
+		
+		
+		/* Print integers */
+			/* print number */
+			switch (qualifier) {
+				case PrintfQualifierByte:
+					size = sizeof(unsigned char);
+					number = (uint64_t)va_arg(ap, unsigned int);
+					break;
+				case PrintfQualifierShort:
+					size = sizeof(unsigned short);
+					number = (uint64_t)va_arg(ap, unsigned int);
+					break;
+				case PrintfQualifierInt:
+					size = sizeof(unsigned int);
+					number = (uint64_t)va_arg(ap, unsigned int);
+					break;
+				case PrintfQualifierLong:
+					size = sizeof(unsigned long);
+					number = (uint64_t)va_arg(ap, unsigned long);
+					break;
+				case PrintfQualifierLongLong:
+					size = sizeof(unsigned long long);
+					number = (uint64_t)va_arg(ap, unsigned long long);
+					break;
+				case PrintfQualifierPointer:
+					size = sizeof(void *);
+					number = (uint64_t)(unsigned long)va_arg(ap, void *);
+					break;
+				case PrintfQualifierSizeT:
+					size = sizeof(size_t);
+					number = (uint64_t)va_arg(ap, size_t);
+					break;
+				default: /* Unknown qualifier */
 					return -counter;
+					
 			}
-			++j;
+			
+			if (flags & __PRINTF_FLAG_SIGNED) {
+				if (number & (0x1 << (size*8 - 1))) {
+					flags |= __PRINTF_FLAG_NEGATIVE;
+				
+					if (size == sizeof(uint64_t)) {
+						number = -((int64_t)number);
+					} else {
+						number = ~number;
+						number &= (~((0xFFFFFFFFFFFFFFFFll) <<  (size * 8)));
+						number++;
+					}
+				}
+			}
+
+			if ((retval = print_number(number, size, base, flags)) == EOF ) {
+				return -counter;
+			};
+
+			counter += retval;
+			j = i + 1;
 		}	
+next_char:
+			
 		++i;
 	}
Index: ns/Makefile
===================================================================
--- ns/Makefile	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ ns/Makefile	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -32,4 +32,5 @@
 LIBC_PREFIX = ../libc
 LIBIPC_PREFIX = ../libipc
+SOFTINT_PREFIX = ../softint
 include $(LIBC_PREFIX)/Makefile.toolchain
 
Index: ns/ns.c
===================================================================
--- ns/ns.c	(revision c05290e81f6086d8e04804e4279b9b263b794033)
+++ ns/ns.c	(revision 11a4fbf3d932714911471f5631d3814591b6851e)
@@ -18,13 +18,13 @@
 	while (1) {
 		callid = ipc_wait_for_call(&call, 0);
-		printf("Received call from: %P..%Q\n", &call.taskid,call.taskid);
+		printf("Received call from: %P..%llX\n", &call.taskid,call.taskid);
 		switch (IPC_GET_METHOD(call.data)) {
 		case IPC_M_CONNECTTOME:
-			printf("Somebody wants to connect with phoneid %d...accepting\n", IPC_GET_ARG3(call.data));
+			printf("Somebody wants to connect with phoneid %zd...accepting\n", IPC_GET_ARG3(call.data));
 			service = IPC_GET_ARG3(call.data);
 			retval = 0;
 			break;
 		case IPC_M_CONNECTMETO:
-			printf("Somebody wants to connect to: %d\n",
+			printf("Somebody wants to connect to: %zd\n",
 			       IPC_GET_ARG1(call.data));
 			retval = 0;
@@ -43,5 +43,5 @@
 			break;
 		default:
-			printf("Unknown method: %d\n", IPC_GET_METHOD(call.data));
+			printf("Unknown method: %zd\n", IPC_GET_METHOD(call.data));
 			retval = ENOENT;
 			break;
