First question here. :)
I have this dumped code from msp430-objdump, the important sections I pasted bellow.
0000f806 <__init_stack>:
f806: 31 40 80 02 mov #640, r1 ;#0x0280
0000f82c <main>:
f82c: 04 41 mov r1, r4
f82e: 24 53 incd r4
f830: 31 50 fa ff add #-6, r1 ;#0xfffa
f834: 94 43 f8 ff mov #1, -8(r4) ;r3 As==01, 0xfff8(r4)
f838: a4 43 fa ff mov #2, -6(r4) ;r3 As==10, 0xfffa(r4)
f83c: 1f 44 f8 ff mov -8(r4), r15 ;0xfff8(r4)
f840: 1f 54 fa ff add -6(r4), r15 ;0xfffa(r4)
f844: 84 4f fc ff mov r15, -4(r4) ;0xfffc(r4)
f848: 0f 43 clr r15
f84a: 31 50 06 00 add #6, r1 ;#0x0006
It is a very simple program, just for test of the development flow. What is awkward to me is that when I print the address values
from the variables in the msp430-gdb I get the following:
(gdb) p &a $5 = (int *) 0x278 (gdb) p &b $6 = (int *) 0x27a (gdb) p &c $7 = (int *) 0x27c (gdb)
Taking as example this two lines:
f834: 94 43 f8 ff mov #1, -8(r4) ;r3 As==01, 0xfff8(r4) f838: a4 43 fa ff mov #2, -6(r4) ;r3 As==10, 0xfffa(r4)
We have two mov instructions that are accually loading the constants 1 and 2 into the memory addresses represented
by 0xfff8(r4) and 0xfffa(r4), we know that r4 has the value 0x282 because was first loaded with r1=0x0280 then
incremented by 2 with incd. But if we add 0xfff8 to 0x0282 we get 0x027A with a carry, which is different from the value
printed in the gdb.
What am I doing wrong here?