the value of data1 i expect is 0x000000A0, but when i execute the above code, it shows a value of 0xFFFFFFA0. I am not understanding why it should add 0xFFFFFF in previous byte.
I am using Keil IDE-Version: µVision3 V3.60 and C Compiler: C51.Exe V8.12
Thank you for enlightening me about unsigned... i forgot about it though
But, if i go back and see the mistake i did..
without keyword 'unsigned' it was considering as signed long and singed char [if i am right], but is it natural for any complier to add FF when it is typecasting to long int ?? why should it do ?? can you please explain ?
I think the FFFFh your are getting is after rotating and shifting signed number. See about how ROL, ROR, SHL, SHR works for signed and unsigned numbers. If it doesn't append Fh or 0b1 to the sign bit then the sign changes while rotating or shifting.