This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Undesired jump between functions (bind handler)

Hi everyone,

I wrote the following code to bind a function and a "number".

I test the bindHandlerInit() in the main and it works.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ------------------------------------------------------------------------- */
// CONSTANT DEFINITION
/* ------------------------------------------------------------------------- */
#define C_HANDLER_ARRAY_SIZE 256
#define C_NULL ((void*) 0L)
/* ------------------------------------------------------------------------- */
// TYPES DEFINITION
/* ------------------------------------------------------------------------- */
typedef unsigned short t_int16u;
typedef unsigned char t_int8u;
typedef t_int8u t_handlerId;
typedef struct
{
t_handlerId type;
t_int8u data[5];
t_int8u dataSizeInBytes;
} t_frame;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

However, when I add a new t_functionHandler array (uncomment line 32), the code do strange things

Fullscreen
1
//static t_functionHandler s_handlerTable2[C_HANDLER_ARRAY_SIZE];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Indeed, after executing the "bindHandler(0, process);" command (line 68), the program jump to line 80 (s_storeDataHere = p_Frame->data[0];) instead of reaching line 53 to finish the main.

When we at line 72 in the C code, we are at adress 0x20000218 in the assembly code.

When we at line 75 in the C code, we are at adress 0x2000021E in the assembly code.

I really don't understand this behaviour.

What is the probleme ?

Thank you for your help.

Best regards.

Rémi G.

  • I do not think there is an actual problem. You're not jumping into another function, but rather the optimizer found that the end of one function is exactly equivalent to the entire "do-nothing" content of the next, so there's no particular reason to emit that same code twice in a row.

    To test this theory, make "process" actually do something, and then see what happens.

    • The probleme was that my heap memory was to big and took space on RAM. 

      When I added the new array, there was not enough space for its. 

      So I reduced the size of the heap memory and it works !

      0