I have a function which is meant to catch all the interrupt calls that will happen, But I cannot get any function to start at address 04.
Note: I dont want to use functions that are specific to interrupt types, I dont want the overhead they produce in the code.
I have tried the following codes with SDCC, maybe not quite related but I will keep them here just in case.
__code __at (4) void handler() {
And
void __at (4) handler() {
With no luck, the manual does not explain any further also.
I know it's a long time after the original question, but I am searching for the same answer and found this helpful info, confirmed working on SDCC 3.3.0: (Source: http://www.mail-archive.com/sdcc-user@lists.sourceforge.net/msg00411.html)
To cause a function to be linked a a fixed, known address, you can surround the function with two other functions: See example below. NOTE: all the _ are double _ _ characters! (You can also define the macros as in the above example, if you intend to use this multiple times throughout your code.
REPLACE #### with your function's desired address below:
test.c
void begin_absolute_code(void) __naked
{
__asm
.area ABSCODE (ABS,CODE)
.org 0x#### // YOUR FUNCTION'S DESIRED ADDRESS HERE.
__endasm;
}
void your_function(...)
{
// Do stuff here. This code will be placed at the specified address.
}
void end_absolute_code(void) __naked
{
__asm
.area CSEG (REL,CODE)
__endasm;
}
void other_functions_here(...)
// These functions will return to relative positions determined by the linker.
Hope this is helpful!