devkitPro / libgba

C Library for Nintendo GBA
http://devkitpro.org/viewforum.php?f=5
Other
189 stars 26 forks source link

this change allows to force the compiler to put the code of a functio… #11

Closed maraflush closed 8 months ago

maraflush commented 2 years ago

Hello,

Sometimes, I need to change my code with thumb or arm mode for specific usage. These attributes can help for us.

Regards,

DacoTaco commented 2 years ago

looking at this ive started to get confused how this all works. online i can only find examples that set the target without the . in the name, and ive been using the same in starstruck. '.arm' or '.thumb' also works?

maraflush commented 2 years ago

Yes, you can force the compiler to use thumb or arm with this update like

THUMB_CODE u16 sum_function() {
  u16 i;
  u16 sum = 0;
  for (i = 0 ; i < 10 ; i++) {
    sum += 1;
  }
  return sum;
}
maraflush commented 2 years ago

looking at this ive started to get confused how this all works. online i can only find examples that set the target without the . in the name, and ive been using the same in starstruck. '.arm' or '.thumb' also works?

How you use this .arm and .thumb in C code ?

LunarLambda commented 2 years ago

It's target("arm") and target("thumb"). See GCC ARM function attributes and libseven's macros.

DacoTaco commented 2 years ago

It's target("arm") and target("thumb"). See GCC ARM function attributes and libseven's macros.

^this is what i meant^ https://github.com/DacoTaco/StarStruck/blob/master/kernel/source/scheduler/threads.c#L139-L140 (and i know this works because its executing arm only instructions and the project is set to build as thumb unless specified otherwise)

maraflush commented 2 years ago

ah ok ! thanks !

maraflush commented 2 years ago

it's better thanks.