Hi, > (looked into lst file and checked the content of the hex file). > > When there are no interrupt routine specified, the main code was put directly > to 0x00 address. > It works, but not good practice, because it overlaps the interrupt vectors. > Even without interrupt routines defined, the interrupt vectors should be kept > and single retfie instructions should be put to adress 0x08 and 0x18. > > In second case, with interrupt routine: The interrupt vector 0x08 contains a > goto instruction, > but there is nothing in reset vector (0x00) > The resulted hex file begins at address 0x08. > This is totally bad. > > I tried to add libsdcc.lib libm18f.lib and libcrt0.lib. > Nothing changed. > > What should I do?
As others pointed out already, you should let sdcc do the linking. In your case, you are missing crt0i.o (note: this is a plain .o file, not libcrt0.lib; also note the "i", which indicates that the crt file initializes your RAM), which provides the RESET interrupt handler and calls __sdcc_gsinit_startup to initialize global and static variables. Linking manually, the next problem will be linker errors such as __gptrget1 not found as soon as you start using pointers. These routines are provided by libsdcc.lib. See $ sdcc -mpic16 -p18f46k22 --use-non-free -V main.c to find out what needs to be linked in (and in what order). Generally, let sdcc do the linking whenever possible to avoid such problems. Best regards Raphael ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user