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

Differences between "LDR r4, =0x50013ffc " and making the address 0x50013ffc using several instructions in thumb16- cortex M3

Hello,
I wrote a program in assembly using thumb 16 instructions for ARM M3 (LPC1313FBD48), (I just want to use thumb16 instructions in the program).
I need to change the value in address: 0x50003ffc.
According to developer.arm.com/.../Constant-and-immediate-values, regarding the device that I am using, there are two ways for creating this address:
1) LDR, r0=0x50003ffc
2) producing the address 0x50003ffc
The code is like below:
the_func.S:
.syntax unified
.text
.thumb
.global my_func
.func my_func
my_func:
push {lr}
push {r4-r7}
inst1
inst2
inst3
@{ ldr r4, =0x50013ffc, ..., and changing r4, ...}
or
@{ creating the address 0x50013ffc, ..., and changing r4, ...}
pop {pc}
pop {r4-r7}
.endfunc
I tried both ways, they compiled. But when I measure the power consumption of the device when it is running the function, the traces are different. Please notice that the power consumption which is recorded is related to the below part of the code:
the_func.S:
.syntax unified
.text
.thumb
.global my_func
.func my_func
my_func:
push {lr}
push {r4-r7}
inst1
inst2
inst3
The power consumption related to the rest of the code is not measured.
(I tried several times. Several times for way 1 and several times for way 2. Every time, the traces are different, however, all traces with way1 are equal, and all traces with way 2 are the same. But these two sets of traces are different.)
In addition, regarding the below items, I don't think that "LDR r4, =0x50013ffc" is not supported in thumb16.
1) "Thumb 16-bit Instruction Set" in load operation we have (from thumb16): PC-relative | LDR Rd, <label> | Rd := [label] | label range PC to PC+1020 (word-aligned).
2) the disassembe of "ldr r4, =0x50013ffc" instruction
(by using the command: arm-none-eabi-objdump -D -bbinary -marm isw_2.bin -Mforce-thumb > isw_2_me.asm)
[ldr r4, =0x50013ffc] == [1f6: 4c19 ldr r4, [pc, #100] ; (0x25c)]

Now, the question is WHY there are different???
Thank you in advance