We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, Can anyone help me with the following problem? I'm writing a long data to a long variable but instead of passing 4 Bytes it pass 3 Bytes. I'm using C51 v6.22. long var = 0xBD3C00BD; -> var=0x3C00BD; Thanks a lot, Reuven
Try unsigned long and see what happens.
Have you tried putting the 'L' on the end of the constant, to force the compiler to treat it as a long?
I tryed unsigned long. I tryed L at the end of the number - NOT WORKING!!!
Really? Then the Keil compiler is completely broken. Hmm, I doubt that. How are you inspecting the value? Don't say printf(). If you say printf() then besure you tell printf() that the object to be printed is of type %lu or %lX. Remember too that in the small model printf will only handle up to 15 bytes of stacked args, 40 in the large model (I think). So if you're printing this 4 byte unsigned long after a bunch of other longs you'll get garbage.
Have you looked at the generated assembler code?
OK, after some invastigations I think the problem is in my emulator. In the *.LST file is see that the compiler take 4 bytes for this variable, so now I'm waiting for some answares from Ceibo (emulator's company).