Paolo Patierno replied to Bruce Eitman [eMVP]
09-Feb-10 03:23 AM

Hi Bruce....you are right....following the ASSEMBLY code of Compute()
function and main() :
Compute()
..
; 21 : DEBUGMSG(TRUE, (TEXT("pBytes=%u"),
*((UINT32*)pBytes->Factory.SerialNumber)));
00010 e59d300c ldr r3, [sp, #0xC]
00014 e283300d add r3, r3, #0xD
00018 e5931000 ldr r1, [r3]
0001c e59f0020 ldr r0, [pc, #0x20]
00020 eb000000 bl NKDbgPrintfW
..
..
main()
..
; 53 : DEBUGMSG(TRUE, (TEXT("SerialNumber=%u"),
*((UINT32*)ccData.Factory.SerialNumber)));
00104 e5dd3010 ldrb r3, [sp, #0x10]
00108 e1a02403 mov r2, r3, lsl #8
0010c e5dd300f ldrb r3, [sp, #0xF]
00110 e1833002 orr r3, r3, r2
00114 e1a02403 mov r2, r3, lsl #8
00118 e5dd300e ldrb r3, [sp, #0xE]
0011c e1833002 orr r3, r3, r2
00120 e1a02403 mov r2, r3, lsl #8
00124 e5dd300d ldrb r3, [sp, #0xD]
00128 e1831002 orr r1, r3, r2
0012c e59f003c ldr r0, [pc, #0x3C]
00130 eb000000 bl NKDbgPrintfW
..
..
In the main(), the compiler generates 4 access in memory that read one byte
at time (byte aligned) and build the UINT32 into internal registry (using r2
and r3) so the access does not rise exception because it is byte aligned. In
the compute(), the compiler generates 1 direct access to the address that
is not aligned to UINT32 (4 bytes).
Thanks,
Paolo
--
Paolo Patierno
Embedded Software Engineer