head	1.9;
access;
symbols
	RELENG_1:1.7;
locks; strict;
comment	@# @;


1.9
date	2004.02.27.17.06.06;	author coppice;	state dead;
branches;
next	1.8;

1.8
date	2003.04.08.19.20.41;	author diwil;	state Exp;
branches;
next	1.7;

1.7
date	2002.07.11.12.52.03;	author diwil;	state Exp;
branches;
next	1.6;

1.6
date	2002.06.26.11.52.54;	author diwil;	state Exp;
branches;
next	1.5;

1.5
date	2002.06.14.07.30.06;	author diwil;	state Exp;
branches;
next	1.4;

1.4
date	2002.06.14.05.56.52;	author diwil;	state Exp;
branches;
next	1.3;

1.3
date	2002.06.13.09.06.31;	author diwil;	state Exp;
branches;
next	1.2;

1.2
date	2002.05.21.07.18.11;	author diwil;	state Exp;
branches;
next	1.1;

1.1
date	2002.05.13.09.00.00;	author diwil;	state Exp;
branches;
next	;


desc
@@


1.9
log
@Remove old files that have been confusing people.
@
text
@# $Id: FAQ,v 1.8 2003/04/08 19:20:41 diwil Exp $

Mspgcc FAQ.
This FAQ covers mspgcc features.


1. Coding interurpts in mspgcc.
Q. In the IAR compiler you can write interrupts in C. Can you do this with
GCC compiler?
A. Yes. The interrupt coding is very similar to IARs one. When you writing
ISR, you have to include io.h and signal.h
Interrupt API looks like:

#include <io.h>
#include <signal.h>

interrupt (INTERRUPT_VECTOR) IntServiceRoutine(void) {...}

Check doc for more info. Do not forget to specify the mcu arch.


2. Missing symbols.
Q. When I link my files with msp430-ld it keeps saying:
undefined reference to `__stop_progExec__'. What's that?
A. You forgot to link a couple of things - startup code, interrupt
vectors and libraries. So, the proper link command looks like:

msp430-ld -m msp430x[arch]
/usr/local/msp430/bin/../lib/gcc-lib/msp430/3.0/../../../../msp430/lib/crt430x[arch].o
-L/usr/local/msp430/bin/../lib/gcc-lib/msp430/3.0/msp1
-L/usr/local/msp430/bin/../lib/gcc-lib/msp430/3.0
-L/usr/local/msp430/bin/../lib/gcc-lib
-L/usr/local/msp430//lib/gcc-lib/msp430/3.0/msp1
-L/usr/local/msp430//lib/gcc-lib/msp430/3.0
-L/usr/local/msp430/bin/../lib/gcc-lib/msp430/3.0/../../../../msp430/lib/msp1
-L/usr/local/msp430/bin/../lib/gcc-lib/msp430/3.0/../../../../msp430/lib
-L/usr/local/msp430//lib/gcc-lib/msp430/3.0/../../../../msp430/lib/msp1
-L/usr/local/msp430//lib/gcc-lib/msp430/3.0/../../../../msp430/lib
-L/usr/local/msp430/bin/../lib/gcc-lib/msp430/3.0/../../..
[object file].o -lgcc -lc -lgcc

Please note, that if you're using arch  with hardware multiplier, 'msp1'
should be changed to 'msp2'.

Bit simpler way is to use msp430-gcc as a linker. In this case just type:
msp430-gcc -mmcu=[arch] obj1.o obj2.o ... -o outputfile -L[extra libraries path] -l[extra libs]


3. Uploading code to mcu.
Q. How to make MCU running?
A. Read pyBSL instructions. This helps ;)


4. Makefiles.
Q. How to write Makefiles?
A. The makefiles are not a part of mspgcc project. Documentation can be
found at http://www.gnu.org/software/make/make.html


5. Putting code at specific address.
Q. My problem is that I don't know how to tell GCC where to place my code.
   My code space must start at 0xd400...How do I tell it where to place the
   code segment?
A. There are two ways to do this:
1. Rework linker script and define that section ".text" starts from 0xd400.
2. Create an attribute defenition:
#define MY_SECTION __attribute__((section(".newsection")))
(This attribute can be combined with any attribute described above)
In every function defenition (and forward declaration) add this 
attribute as:
	type MY_SECTION function(params...);
Do the same with constants declaration if necessary:
	const MY_SECTION type my_const = MY_VALUE;
In command line define the section along with other compile options:
msp430-gcc -Wl,--section-start -Wl,.newsection=0xd400 [other necessary options and files]

Please also keep in your mind, that startup code (if linked) will start from
the ROM's first address. Its size is 0x40 (including _reset_vector__(),
_unexpected_() and _unexpected_1_() providing last two are not redefined in
user code).

6. Frame Address. 
Q. IAR provide a function to get a frame address which
   means u have more control. Does anyone know of a similar function supported
   by mspgcc?
A. Gcc provides a function which is __builtin_frame_address(LEVEL) but this
will not help you much (only if r4 being used as a frame pointer). The
answer has been moved to doc.txt, Appendix A.3, Calls defenition.


7. Long jumps.
Q. I want to jump from an arbitrary place to main(). Is it possible to do it
   in C? 
A. Yes. Depict a circle on the ground, call it "main", walk away, run and
jump. If you check in the circle, then it is possible :)
Within you code you can do it as follows:
// --------------------------------------------------------------------------

#include <setjmp.h>

jmp_buf __jmpb;	// make this global

type first_point_to_jump_from(...) {
	...
	if(something1) {
		longjmp(__jmpb,1);
	}
	...
}

type another_point_to_jump_from(...) {
	...
        if(something2) {
                longjmp(__jmpb,2);
        }
        ...
}

type the_place_to_jump_to() {
	int res;
	...

	res = setjmp(__jmpb);
	if(!res) {
		// not a jump, just a usual program flow
	}
	else if(res == 1) {
		// we jumped here from first subroutine
	}
	else if(res == 2) {
		// we jumped here from another (interrupt service) routine
	}
}
// --------------------------------------------------------------------------
Q. It it possible to jump to several different places? 
A. Draw a couple of circles, or declare a couple of jmp_buf. Every landing
point will have then its own jmp_buf. The setjmp() and longjmp() functions
conform to ISO/IEC 9899:1990 (``ISO C89'').



...Your question here....

diwil@@mail.ru

@


1.8
log
@change link sequence.
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.7 2002/07/11 12:52:03 diwil Exp $
@


1.7
log
@additions
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.6 2002/06/26 11:52:54 diwil Exp $
d46 1
a46 2
msp430-gcc -mmcu=[arch] -L[extra libraries path] -l[extra libs] obj1.o
obj2.o ... -o outputfile
@


1.6
log
@revamp
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.5 2002/06/14 07:30:06 diwil Exp $
d90 50
@


1.5
log
@add .L__FrameOffset_...
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.4 2002/06/14 05:56:52 diwil Exp $
d69 2
a70 1
The in every function defenition (and forward declaration) add this 
d75 1
a75 1
The in command line define the section along with other compile options:
d79 1
a79 1
the ROM's first address. Its size is 0x40 (includeing _reset_vector__(),
d89 1
a89 1
answer has been moved to doc.txt, appendix A.3 Calls defenition.
@


1.4
log
@_ -> __
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.3 2002/06/13 09:06:31 diwil Exp $
d87 2
a88 31
will not help you much (only if r4 being used as a frame pointer). Instead:
you have the following var defined:
	.L__FrameSize_name
	(name - a function name, for example 'main')
which is a frame size. So, the initial frame address can be obtained as
follows:
The first line of function entry will be an assm operand:

int initial_frame_address;

__asm__ __volatile__ (
	"mov	r1, %0\n\t"
	"add	#.L__FrameSize_name, %0"
	: "=r" (initial_frame_address)
	:	/* no inputs */
);

Alternatively, you can use macro GET_FRAME_ADDR(name) from <iomacros.h>
(name is a function name without apostrophes or something.)

#include <io.h>

type myFuncNameInCPLUSPLUSStyleWhichIHate(args....)
{
	/* ....declars.... */
	int initial_frame_address = 
		GET_FRAME_ADDR(myFuncNameInCPLUSPLUSStyleWhichIHate);
	
	/*func body */

}
@


1.3
log
@add
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.2 2002/05/21 07:18:11 diwil Exp $
d89 1
a89 1
	.L_FrameSize_name
@


1.2
log
@new additions
@
text
@d1 1
a1 1
# $Id: FAQ,v 1.1 2002/05/13 09:00:00 diwil Exp $
d81 38
@


1.1
log
@initial
@
text
@d1 1
a1 3
# $Id$


a6 2


d60 21
@

