Jump to content



Photo
- - - - -

Help with optimization


Best Answer TBit , 28 March 2020 - 03:04 AM

I think it depends on which compiler you are using (I assume gcc).

So maybe try different optimization options first. Also, you could make your function pointer constant, like this:

void (*const i)(int, int)

For Casio's SHC, you could try different optimization arguments (-speed, -nospeed,-size) or maybe a 

#pragma section
Go to the full post


  • Please log in to reply
2 replies to this topic

#1 hejsotnoss

hejsotnoss

    Casio Fan

  • Members
  • PipPip
  • 31 posts
  • Gender:Male
  • Interests:programming
    mathematics
    piano
    reading

  • Calculators:
    fx-9750GII
    fx-9860GII

Posted 28 March 2020 - 01:45 AM

I noticed that this code:

void (* i)(int, int) = (void*)0x0;

int main(int isAppli, int OptionNum) {
        i(1, 1);
        return 1;
}

generates this:

  300318:       d1 04           mov.l   0x30032c,r1     ! 8100004
  30031a:       e5 01           mov     #1,r5
  30031c:       4f 22           sts.l   pr,@-r15
  30031e:       61 12           mov.l   @r1,r1
  300320:       41 0b           jsr     @r1
  300322:       e4 01           mov     #1,r4

It seems like the compiler is putting the pointer of the function i into the .data section. Is there any way to change this behavior so that it puts the raw 0x0 pointer into .rodata so that it doesn't need the mov.l @r1,r1?


Edited by hejsotnoss, 28 March 2020 - 02:01 AM.


#2 TBit

TBit

    Newbie

  • Members
  • Pip
  • 26 posts
  • Gender:Male
  • Location:Germany
  • Interests:C/C++, Assembly, Demoscene

  • Calculators:
    FX-9860 GII
    FX-9750 GII
    ClassPad 330 PLUS

Posted 28 March 2020 - 03:04 AM   Best Answer

I think it depends on which compiler you are using (I assume gcc).

So maybe try different optimization options first. Also, you could make your function pointer constant, like this:

void (*const i)(int, int)

For Casio's SHC, you could try different optimization arguments (-speed, -nospeed,-size) or maybe a 

#pragma section

  • hejsotnoss likes this

#3 hejsotnoss

hejsotnoss

    Casio Fan

  • Members
  • PipPip
  • 31 posts
  • Gender:Male
  • Interests:programming
    mathematics
    piano
    reading

  • Calculators:
    fx-9750GII
    fx-9860GII

Posted 28 March 2020 - 03:40 AM

Thank you, a combination of using -O3 and and making the function pointer constant seemed to fix my issue. ^_^




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users