I have some code (generated with msp430-gcc-2.3.2, -O1) that uses an register 
indexed CALL. It's a function pointer call, so maybe a rather uncommon 
operation. gcc generates the register-indexed CALL only when optimizing.

The call goes wrong, and it looks like the index is ignored. Here's the code:

                                        cb(&tmp, i, userdata);

   f0ac:        1d 41 04 00     mov     4(r1),  r13     ;
   f0b0:        0e 4a           mov     r10,    r14     ;
   f0b2:        0f 41           mov     r1,     r15     ;
   f0b4:        91 12 02 00     call    2(r1)           ;


and here's what happens:

(gdb) si
0x0000f0b0      65                                              cb(&tmp, i, 
userdata);
(gdb) 0x0000f0b2 65 cb(&tmp, i, userdata); (gdb) 0x0000f0b4 65 cb(&tmp, i, userdata);
(gdb) p /x $r1
$5 = 0x2c4
(gdb) x 0x2c4
0x2c4:  0xf00046d2
(gdb) si
0x000046d2 in ?? ()
(gdb)
I really want to call 2(r1) (0xf000), but instead the machine seems to jump to 
r1 (0x46d2).
Does this make sense to anyone? Is the generated code bad, or is this a 
processor issue?

Best regards,
Heiko

Reply via email to