This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM7 printf long long int

Hi, my program does not do the expected things, printf a unsigned long long int.

#include <aduc7026.h>
#include"stdio.h"

void RS232_init(void);
int main (void)
{
	unsigned long long int A;
	RS232_init();
	printf("Start \n");
	while(1)
	{
		while(1)
		{
			printf("Enter a Hex-number\n");
			if (scanf("%X",&A)) break;
			scanf("%*");				//Clearing scanf input stream
		}
		printf ("Your input %64.64lX\n",A);
		A *= A;
		printf ("The result %64.64lX\n",A);
	}
}

void RS232_init(void)
{
	GP1CON = 0x011;			// Setup tx & rx pins on P1.0 and P1.1
   							// Start setting up UART at 9600bps
   	COMCON0 = 0x080;		// Setting DLAB
   	COMDIV0 = 0x088;		// Setting DIV0 and DIV1 to DL calculated
   	COMDIV1 = 0x000;
   	COMCON0 = 0x007;		// Clearing DLAB
}
the Output via RS232: Start Enter a Hex-number Your input 0000000000000000000000000000000000000000000000000000000011111111 The result 0000000000000000000000000000000000000000000000000000000087654321 Enter a Hex-number but when stepping through the programm ?C?QMUL?A: 0x00080F78 E08CB290 UMULL R11,R12,R0,R2 0x00080F7C E02CC192 MLA R12,R2,R1,R12 0x00080F80 E021C093 MLA R1,R3,R0,R12 0x00080F84 E1A0000B MOV R0,R11 0x00080F88 E12FFF1E BX R14 after the UMULL the expected result (0x0123456787654321) is in R12/R11 for some just a little moment... Sometimes i think C is the pureness of evil.

Parents
  • "It seems that printf can not print unsigned long long integer"

    There is no "seems" about it - you have just been told explicitly by Reinhard Keil himself that The CARM compiler does not support printout of long long int values.

    Further, you have also been told that the RealView Compiler does support this ANSI C99 extension

    It only remains to check the GCC manual to see wether or not GCC supports it.
    (I have a feeling that GCC does support C99...?)

Reply
  • "It seems that printf can not print unsigned long long integer"

    There is no "seems" about it - you have just been told explicitly by Reinhard Keil himself that The CARM compiler does not support printout of long long int values.

    Further, you have also been told that the RealView Compiler does support this ANSI C99 extension

    It only remains to check the GCC manual to see wether or not GCC supports it.
    (I have a feeling that GCC does support C99...?)

Children
  • "It only remains to check the GCC manual to see wether or not GCC supports it."

    Once you can actually find the manual! :-(
    http://www.keil.com/forum/docs/thread7639.asp

    Here it is:

    http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html#Integer-Conversions

    It says that you can us 'L' (uppercase), 'll' (lowercase), or 'q' to qualify a long long int.

    Note that a single lowercase 'l' still indicates a long int

  • Sorry, your' right.

    See me as someone, who is learning to fly C like the man in the film Those Magnificent Men In Their Flying Machines

    While he flying, he reads the book "Learning to fly in five lessons"

    And suddenly the wind brushes the book away...

    But by the way, what is the difference between all this different compilers?
    Isn't the Keil-Compiler the best in the world?
    I can't say, i came to it like the virgin to a child.
    I just bought this ADuC7026-Eval-Kit.
    There was a CD... i installed it... and here we are.

  • "See me as someone, who is learning to fly C like the man in the film Those Magnificent Men In Their Flying Machines"

    remember - that film is a comedy

    As I've said before, this is not a very effective way to learn 'C'.
    Continuing with the film analogy, you have already landded yourself in the Sewage Farm several times!!


    "But by the way, what is the difference between all this different compilers?"

    As any good textbook will tell you, 'C' has a number of things which are implementation-defined, unspecified, and undefined.

    The stuff we're talking about here is implementation-defined.

    Also, the long long business is an extension to the original ANSI 'C' specification - that's why not all compilers support it!

    "Isn't the Keil-Compiler the best in the world?"

    Which one? There are two!
    http://www.keil.com/arm/