Strange problem compiling with -nostartupfiles.
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    I have a problem very strange, i sure that it's my fault. I wrote a little synth very simple, it stores the song on a char string, the main problem is that i wrote a function to do this called fill_buffer declarared static, if i put modulus, shift bytes or strlib function calls, it hangs directly using -nostartfiles, but works properly without that option. This function it's called inside entry/main function, and inside display function registered as idle function on TinyGL, i tried also to create a macro with the same function and it works with -nostartfiles, but the executable gives some bytes more, so it appears that it doesn't work when i used that operations outside entry or display function. This is part of the code:

    Code:

    static ULONG tbuf = 0, track_note = 0, note = 0;
    static char song[] ="@@EHGHJHGAAHGHJHGCCJHJLJHEHGHJH";

    static void fill_buffer(BYTE* p)
    {
    for (i = 0; i < BUFFERSIZE; i++) {
    if (((tbuf + i + 1) & 1023) == 0){
    track_note ++;
    /*?This mod operation hangs the application,
    using a macro works, and removing mod operation also.
    And it works without -nostartfiles
    */
    note = song[track_note%31]-64;
    }
    p[i] = (i*note)&255;
    }
    tbuf += BUFFERSIZE;
    }
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »24.07.10 - 11:10
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Posts: 423 from 2005/4/9
    From: magyarorszag/h...
    quote from tokai: "the order of the functions matter. you must make sure your main entry routine is first."
    DEAD pegII/G4@1000.1gb ram.radeon 9200pro
    240 gigz hd.nec dvdrw.MorphOS 2.4 DEAD
    -=-=-=-
    amiga1200T.blizzardppc@180/040@25.96megz ram
    -=-=-=-=-
    zx.spectrum@3.5
  • »25.07.10 - 21:58
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Thanks Sadddam, entry function is the first, the code above is only a part of the code, and fill_buffer function is implemented after entry function. An example of how is structured:

    int entry(void) { return 0; }

    static void display{void}

    static void fill_buffer(BYTE *p)

    Anyway i received an email from my webpage from tokai, and suggest me some tips that i will try this night.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »26.07.10 - 08:47
    Profile Visit Website
  • MorphOS Developer
    CISC
    Posts: 619 from 2005/8/27
    From: the land with ...
    Quote:

    Thanks Sadddam, entry function is the first, the code above is only a part of the code, and fill_buffer function is implemented after entry function.


    Be aware that -O3 will reorder functions, therefore you must either use -O2 or put the entry function in a separate file and make sure it is linked first.


    - CISC
  • »26.07.10 - 11:41
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    Thanks CISC for your help, i will check again this night, i was using -Os, i had solved the problem yesterday using gotos, that save some bytes more than using a macro, but i don't like this way, i prefer to use functions.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »26.07.10 - 15:59
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    BalrogSoft
    Posts: 171 from 2006/10/6
    From: Spain
    I changed optimization level to -O2 and now it works, i will publish some code when I will have it more advanced, if it's usefull to someone.
    Balrog Software - AmigaSkool.net
    Mac Mini - MorphOS 3.8 - G4 1.5Ghz - Ati 9200 64 Mb
    Efika - MorphOS 3.6 - Ati 9200 64Mb - 80 Gb HD
    Amiga 1200D - OS 3.9 - Blizzard 603e/240mh
  • »26.07.10 - 20:48
    Profile Visit Website