Hello, I'm using the mspgcc tool chain on a SuSE Linux 9.2 built as described in the documentation. I'm able to compile load and run programs but using the debugger does not work as expected. I' using
GNU gdb 5.1.1 Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=msp430". I compiled and linked the following program: #include "io.h" typedef struct { uint16_t lo; uint16_t hi; double slope; uint16_t pDeepestStop; } GradientFactor; static GradientFactor gf; void GradientFactor_init(uint16_t lo, uint16_t hi); void GradientFactor_reset(void); void GradientFactor_init(uint16_t lo, uint16_t hi) { gf.lo = lo; gf.hi = hi; GradientFactor_reset(); } void GradientFactor_reset() { gf.pDeepestStop = 0; gf.slope = 0.0; } int main(int argc, char **argv) { /* Disable watchdog during initialization */ WDTCTL = WDTPW|WDTHOLD; /* Make all pins to I/O pins */ P1SEL = 0; P2SEL = 0; P3SEL = 0; P4SEL = 0; P5SEL = 0; P6SEL = 0; /* Set all pins to low */ P1OUT = 0; P2OUT = 0; P3OUT = 0; P4OUT = 0; P5OUT = 0; P6OUT = 0; /* Make all pins to output pins */ P1DIR = 0xff; P2DIR = 0xff; P3DIR = 0xff; P4DIR = 0xff; P5DIR = 0xff; P6DIR = 0xff; /* Disable interrupts from port 1 */ P1IES = 0; P1IE = 0; /* Disable interrupts from port 2 */ P2IES = 0; P2IE = 0; /* Set clockspeed */ BCSCTL1 = RSEL2 | RSEL1 | RSEL0; DCOCTL = DCO2 | DCO1 | DCO0; GradientFactor_init((uint16_t)20, (uint16_t)70); return 0; } with: /usr/local/msp430/bin/msp430-gcc -mmcu=msp430x149 -I/usr/local/msp430/msp430/include -pedantic -Wall -Wstrict-prototypes -Winline -g -c simpletest.c-o simpletest.o /usr/local/msp430/bin/msp430-gcc -mmcu=msp430x149 simpletest.o -o simpletest This gives: msp430-objdump -S simpletest simpletest: file format elf32-msp430 Disassembly of section .text: 00001100 <_reset_vector__>: 1100: b2 40 80 5a mov #23168, &0x0120 ;#0x5a80 1104: 20 01 1106: 3f 40 12 12 mov #4626, r15 ;#0x1212 110a: 3e 40 00 02 mov #512, r14 ;#0x0200 110e: 3d 40 00 02 mov #512, r13 ;#0x0200 1112: 0d 9e cmp r14, r13 ; 1114: 05 24 jz $+12 ;abs 0x1120 1116: fe 4f 00 00 mov.b @r15+, 0(r14) ; 111a: 1e 53 inc r14 ; 111c: 0e 9d cmp r13, r14 ; 111e: fb 2b jnc $-8 ;abs 0x1116 1120: 3f 40 00 02 mov #512, r15 ;#0x0200 1124: 3d 40 0a 02 mov #522, r13 ;#0x020a 1128: 0d 9f cmp r15, r13 ; 112a: 05 24 jz $+12 ;abs 0x1136 112c: cf 43 00 00 mov.b #0, 0(r15) ;r3 As==00 1130: 1f 53 inc r15 ; 1132: 0f 9d cmp r13, r15 ; 1134: fb 2b jnc $-8 ;abs 0x112c 1136: 30 40 82 11 br #0x1182 ; 0000113a <__ctors_end>: 113a: 30 40 3e 11 br #0x113e ; 0000113e <_unexpected_>: 113e: 00 13 reti 00001140 <GradientFactor_init>: void GradientFactor_init(uint16_t lo, uint16_t hi); void GradientFactor_reset(void); void GradientFactor_init(uint16_t lo, uint16_t hi) { 1140: 05 12 push r5 ; 1142: 04 12 push r4 ; 1144: 05 41 mov r1, r5 ; 1146: 35 50 06 00 add #6, r5 ;#0x0006 114a: 21 82 sub #4, r1 ;r2 As==10 114c: 04 41 mov r1, r4 ; 114e: 84 4f 00 00 mov r15, 0(r4) ; 1152: 84 4e 02 00 mov r14, 2(r4) ; gf.lo = lo; 1156: a2 44 00 02 mov @r4, &0x0200 ; gf.hi = hi; 115a: 92 44 02 00 mov 2(r4), &0x0202 ; 115e: 02 02 GradientFactor_reset(); 1160: b0 12 6c 11 call #4460 ;#0x116c } 1164: 21 52 add #4, r1 ;r2 As==10 1166: 34 41 pop r4 ; 1168: 35 41 pop r5 ; 116a: 30 41 ret 0000116c <GradientFactor_reset>: void GradientFactor_reset() { 116c: 05 12 push r5 ; 116e: 04 12 push r4 ; gf.pDeepestStop = 0; 1170: 82 43 08 02 mov #0, &0x0208 ;r3 As==00 gf.slope = 0.0; 1174: 82 43 04 02 mov #0, &0x0204 ;r3 As==00 1178: 82 43 06 02 mov #0, &0x0206 ;r3 As==00 } 117c: 34 41 pop r4 ; 117e: 35 41 pop r5 ; 1180: 30 41 ret 00001182 <main>: int main(int argc, char **argv) { 1182: 31 40 fc 09 mov #2556, r1 ;#0x09fc 1186: 04 41 mov r1, r4 ; 1188: 84 4f 00 00 mov r15, 0(r4) ; 118c: 84 4e 02 00 mov r14, 2(r4) ; /* Disable watchdog during initialization */ WDTCTL = WDTPW|WDTHOLD; 1190: b2 40 80 5a mov #23168, &0x0120 ;#0x5a80 1194: 20 01 /* Make all pins to I/O pins */ P1SEL = 0; 1196: c2 43 26 00 mov.b #0, &0x0026 ;r3 As==00 P2SEL = 0; 119a: c2 43 2e 00 mov.b #0, &0x002e ;r3 As==00 P3SEL = 0; 119e: c2 43 1b 00 mov.b #0, &0x001b ;r3 As==00 P4SEL = 0; 11a2: c2 43 1f 00 mov.b #0, &0x001f ;r3 As==00 P5SEL = 0; 11a6: c2 43 33 00 mov.b #0, &0x0033 ;r3 As==00 P6SEL = 0; 11aa: c2 43 37 00 mov.b #0, &0x0037 ;r3 As==00 /* Set all pins to low */ P1OUT = 0; 11ae: c2 43 21 00 mov.b #0, &0x0021 ;r3 As==00 P2OUT = 0; 11b2: c2 43 29 00 mov.b #0, &0x0029 ;r3 As==00 P3OUT = 0; 11b6: c2 43 19 00 mov.b #0, &0x0019 ;r3 As==00 P4OUT = 0; 11ba: c2 43 1d 00 mov.b #0, &0x001d ;r3 As==00 P5OUT = 0; 11be: c2 43 31 00 mov.b #0, &0x0031 ;r3 As==00 P6OUT = 0; 11c2: c2 43 35 00 mov.b #0, &0x0035 ;r3 As==00 /* Make all pins to output pins */ P1DIR = 0xff; 11c6: f2 43 22 00 mov.b #-1, &0x0022 ;r3 As==11 P2DIR = 0xff; 11ca: f2 43 2a 00 mov.b #-1, &0x002a ;r3 As==11 P3DIR = 0xff; 11ce: f2 43 1a 00 mov.b #-1, &0x001a ;r3 As==11 P4DIR = 0xff; 11d2: f2 43 1e 00 mov.b #-1, &0x001e ;r3 As==11 P5DIR = 0xff; 11d6: f2 43 32 00 mov.b #-1, &0x0032 ;r3 As==11 P6DIR = 0xff; 11da: f2 43 36 00 mov.b #-1, &0x0036 ;r3 As==11 /* Disable interrupts from port 1 */ P1IES = 0; 11de: c2 43 24 00 mov.b #0, &0x0024 ;r3 As==00 P1IE = 0; 11e2: c2 43 25 00 mov.b #0, &0x0025 ;r3 As==00 /* Disable interrupts from port 2 */ P2IES = 0; 11e6: c2 43 2c 00 mov.b #0, &0x002c ;r3 As==00 P2IE = 0; 11ea: c2 43 2d 00 mov.b #0, &0x002d ;r3 As==00 /* Set clockspeed */ BCSCTL1 = RSEL2 | RSEL1 | RSEL0; 11ee: f2 40 07 00 mov.b #7, &0x0057 ;#0x0007 11f2: 57 00 DCOCTL = DCO2 | DCO1 | DCO0; 11f4: f2 40 e0 ff mov.b #-32, &0x0056 ;#0xffe0 11f8: 56 00 GradientFactor_init((uint16_t)20, (uint16_t)70); 11fa: 3e 40 46 00 mov #70, r14 ;#0x0046 11fe: 3f 40 14 00 mov #20, r15 ;#0x0014 1202: b0 12 40 11 call #4416 ;#0x1140 return 0; 1206: 0f 43 clr r15 ; } 1208: 21 52 add #4, r1 ;r2 As==10 120a: 30 40 0e 12 br #0x120e ; 0000120e <__stop_progExec__>: 120e: 02 df bis r15, r2 ; 1210: fe 3f jmp $-2 ;abs 0x120e Disassembly of section .vectors: 0000ffe0 <InterruptVectors>: ffe0: 3a 11 3a 11 3a 11 3a 11 3a 11 3a 11 3a 11 3a 11 :.:.:.:.:.:.:.:. fff0: 3a 11 3a 11 3a 11 3a 11 3a 11 3a 11 3a 11 00 11 :.:.:.:.:.:.:... When I set a breakpoint at the first statement of the function GradientFactor_init() the execution stops at this line. Using the command "info args" gives: lo = 522 hi = 512 and not 20 and 70 as expected. Stepping two lines further and looking at gf with: p gf $1 = {lo = 20, hi = 70, slope = 0, pDeepestStop = 0} shows the expected values. I would be very happy if someone on this list could give me a hint what I'm doing wrong. Regards, Martin