Hi,
First of all, VisualGDB uses the mspgcc compiler to build code for msp430, so many tricks that work for gcc/mspgcc will work with VisualGDB.
Regarding the initialization code, you need to make a separate function and put it to one of the .initX sections:
;; .init0 (_reset_vector__: Start here after reset)
;; .init1 (User definable)
;; .init2 (__init_stack: Initialize stack)
;; .init3 (__low_level_init: Initialize hardware; user definable)
;; .init4 (__do_copy_data; __do_clear_bss: Copy data to .data, clear bss)
;; .init5 (User definable)
;; .init6 (__do_global_ctors: C++ constructors)
;; .init7 (User definable)
;; .init8 (User definable)
;; .init9 (main)
;; .fini9 (__stop_progExec__: Falls into here after main(). User definable)
;; .fini8 (User definable)
;; .fini7 (User definable)
;; .fini6 (C++ destructors)
;; .fini5 (User definable)
;; .fini4 (User definable)
;; .fini3 (User definable)
;; .fini2 (User definable)
;; .fini1 (User definable)
;; .fini0 (_endless_loop__: Infinite loop after program termination)
E.g. the following function will be placed to .init5 and hence will be executed after copying data from FLASH to RAM but before invoking C++ constructors :
void __attribute__((naked, section(".init5"))) MyInitializationCode()
{
asm("nop");
}
Note that the function body will be “copy-pasted” into the initialization sequence, hence the function should not contain any prologue/epilogue and must be declared as ‘naked’ (it may call other functions though).