Please help
Posted: Sun Apr 24, 2005 12:24 am
Hi all,
I have 2 binary files in my embedded system. One file is compiled with 16-bit code alignment and the other with 32-bit code alignment. I have a structure declared in the 16 bit code. I pass the address of the structure to a function in the 32 bit code and assign a value in the structure member (int). When I print the value after assigning the variable in the same function, it is found to be correct. But, when I print the value after returning from the function in the 16 bit code, the value seems to be incorrect. For example, if I assign 0x23 in the 32 bit code, i get 0x2300 in the 16 bit code. Why does this happen? The processor is Motorola 68020. Compiler mcc68k, Assembler asm68k, Linker lnk68k. When both the code were 16 bit aligned, there was no problem. But, I face this problem only after converting a binary to 32 bit code.
And, another question, what should be the size of a pointer in the 16 bit code? Shouldn't be 2 bytes? But, I get 4 bytes as the size of the integer both in 16 bit and 32 bit code. I am totally confused. Please, help me out of this problem.
Any help greatly appreciated.
Thanks.
I have 2 binary files in my embedded system. One file is compiled with 16-bit code alignment and the other with 32-bit code alignment. I have a structure declared in the 16 bit code. I pass the address of the structure to a function in the 32 bit code and assign a value in the structure member (int). When I print the value after assigning the variable in the same function, it is found to be correct. But, when I print the value after returning from the function in the 16 bit code, the value seems to be incorrect. For example, if I assign 0x23 in the 32 bit code, i get 0x2300 in the 16 bit code. Why does this happen? The processor is Motorola 68020. Compiler mcc68k, Assembler asm68k, Linker lnk68k. When both the code were 16 bit aligned, there was no problem. But, I face this problem only after converting a binary to 32 bit code.
And, another question, what should be the size of a pointer in the 16 bit code? Shouldn't be 2 bytes? But, I get 4 bytes as the size of the integer both in 16 bit and 32 bit code. I am totally confused. Please, help me out of this problem.
Any help greatly appreciated.
Thanks.