Menu

SDCC stm8 code modification

Help
htio
2014-11-03
2014-11-15
  • htio

    htio - 2014-11-03

    Hi,

    I modify the code in stm8/main.c but the output remains the unmodify one, please advise me on what have I done wrong. below are the changes and steps that I have taken:

    1step)-------------------------------------------------------------------------------------
    I did the folloing changes to stm8/main.c

    stm8_genInitStartup(FILE * of)
    {
    fprintf (of, "__sdcc_gs_init_startup:\n");

    / Init static & global variables /
    fprintf (of, "__sdcc_init_data:\n");
    fprintf (of, "; stm8_LWB_genXINIT() start\n");<- change from stm8_genXINIT() to stm8_LWB_genXINIT()
    ...
    }

    2step)----------------------------------------------------------------------------------------
    compile the sdcc sorce code via Visual Studio:
    1>------ Build started: Project: yacc, Configuration: Debug Win32 ------
    2>------ Build started: Project: stm8, Configuration: Debug Win32 ------
    2> main.c
    2> stm8.vcxproj -> C:\Users\htio\Downloads\sdcc-src-20141013-9085.tar\sdcc\src\stm8\Debug\port.lib
    3>------ Build started: Project: sdcc, Configuration: Debug Win32 ------
    3>cdbFile.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
    3> sdcc.vcxproj -> C:\Users\htio\Downloads\sdcc-src-20141013-9085.tar\sdcc\src..\bin_vc\sdcc.exe
    ========== Build: 3 succeeded, 0 failed, 20 up-to-date, 0 skipped ==========

    3step)------------------------------------------------------------------------------------------
    compile the C code (Testing.c) with the newly build sdcc compiler via Cygwin:
    $ sdcc.exe -mstm8 Testing.c
    ?ASlink-Warning-Undefined Global '__mulint' referenced by module 'Testing'
    Testing.c:5: warning 212: support for long long literals is incomplete
    Testing.c:7: warning 126: unreachable code

    4step)-------------------------------------------------------------------------------------------
    but the output in Testing.asm remains the same as stm8_genXINIT() although I change it to stm8_LWB_genXINIT() in the sdcc source code... Please advise
    ;--------------------------------------------------------
    ; global & static initialisations
    ;--------------------------------------------------------
    ...
    ; stm8_genXINIT() start <------------ should change to "stm8_LWB_genXINIT() start"
    ldw x, #l_DATA
    jreq 00002$
    00001$:
    clr (s_DATA - 1, x)
    decw x
    jrne 00001$
    ...

    Thanks,
    Htio

     

    Last edit: htio 2014-11-03
  • Ben Shi

    Ben Shi - 2014-11-03

    $ sdcc.exe -mstm8 Testing.c

    Is this xdcc.exe the one you newly built one ?

    Can you try absolute path C:\Users\htio\Downloads\sdcc-src-20141013-9085.tar\sdcc\src..\bin_vc\sdcc.exe ?

     
  • htio

    htio - 2014-11-03

    Hi,

    htio@HTIO /cygdrive/c/Users/htio/Downloads/sdcc-src-20141013-9085.tar/sdcc/bin_vc
    $ sdcc.exe -mstm8 Testing.c

    ?ASlink-Warning-Undefined Global '__mulint' referenced by module 'Testing'
    Testing.c:5: warning 212: support for long long literals is incomplete
    Testing.c:7: warning 126: unreachable code

    Yes, it is.

    Thanks,
    Htio

     
  • htio

    htio - 2014-11-03

    Hi,

    Ok i did the absolute path and it went trough but i got another error:

    Microsoft Visual C++ Runtime Libary:
    Debug Assertion Fail!
    Program:C:\cygwin\home\htio...\sdcc.exe
    Fille:c:\program files (x86)\microsoft visual studio 11.0\vc\include\list
    Line:1692

    Expression: invalid operator<

    ...

    Please advise.

    Thanks,
    htio

     
  • Ben Shi

    Ben Shi - 2014-11-03

    I use MacOS and can not reproduce your trouble. But I suggest you link sdcc statically, and use the release mode other than debug mode.

    Since sdcc is built daily on sdcc.sourceforge.net/snap.php (there are both win32 and win64), you should not get any trouble with the latest source code.

     
  • htio

    htio - 2014-11-04

    Hi,

    I do some diging and here is the code i added in SDCCralloc.hpp:

    ...
    996 printf("htio is here\n");
    997 printf("c0:%d, t:%d\n",T[c0].bag.size(),T[t].bag.size());
    998 T[c0].bag.size() < T[t].bag.size() ? tree_dec_ralloc_introduce(T, t, G, I, ac, assignment_optimal) : tree_dec_ralloc_forget(T, t, G, I);
    999 printf("htio is here bye\n");
    ...

    and the output is:
    Testing.c:5: warning 212: support for long long literals is incomplete
    Testing.c:7: warning 126: unreachable code
    htio is here
    c0:0, t:1
    htio is here bye.
    htio is here
    c0:1, t:2
    htio is here bye.
    htio is here
    c0:2, t:1
    htio is here bye.
    htio is here
    c0:1, t:2
    htio is here bye.
    htio is here
    c0:2, t:1
    htio is here bye.
    htio is here
    c0:1, t:2
    htio is here bye.
    htio is here
    c0:2, t:1
    htio is here bye.
    htio is here
    c0:1, t:2
    htio is here bye.
    htio is here
    c0:2, t:1
    Caught signal 22: SIGABRT

    so I think the error occurs in line 997, correct me if i'm wrong, is there a fix for this ?

    Thanks,
    Htio

     

    Last edit: htio 2014-11-04
    • Philipp Klaus Krause

      On 04.11.2014 02:59, htio wrote:

      Hi,

      I do some diging and here is the code i added in SDCCralloc.hpp:

      ...
      996 printf("htio is here\n");
      997 T[c0].bag.size() < T[t].bag.size() ? tree_dec_ralloc_introduce(T, t,
      G, I, ac, assignment_optimal) : tree_dec_ralloc_forget(T, t, G, I);
      998 printf("htio is here bye\n");
      ...

      and the output is:
      Testing.c:5: warning 212: support for long long literals is incomplete
      Testing.c:7: warning 126: unreachable code
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      htio is here bye.
      htio is here
      Caught signal 22: SIGABRT

      so I think the error occurs in line 997, correct me if i'm wrong, is
      there a fix for this ?

      Thanks,
      Htio

      That seems weird, as I cannot see what the issue with the < on that line
      could be. Maybe Maarten can help, AFAIK he is the one doing builds with
      MSVC.

      Philipp

       
  • Ben Shi

    Ben Shi - 2014-11-04

    I can not give any useful suggestion since I have no MS-Win environment. The only way seems remaining is you strictly following steps on the manual of building SDCC on Win.

     
  • htio

    htio - 2014-11-12

    Hi,

    its an old issue ... the error is from lib function boost() when it call sort(). Cant seems to fix this by reinstalling boost, switched to Cygwin and the code is runing just fine.

    I am doing a port for a new architecture for my company, I cant share much cos the company wants to keep this processor confidential... hope you can understand. The processor is an 8bit processor and has like 15 registers and the architecture is not like any existing port. As I go trough sdcc code, I am kind of stuck at porting the rough_cost_estimate() function, where the way you calculate the cost... if there any tips you can give me ?

    Thanks,
    Htio

     
    • Philipp Klaus Krause

      Are these 15 registers interchangeable? How wide are they? 8 bits?

      rough_cost_estimate() is just for the register allocation heuristic. When writing a new port, I would first make this just return 0.0f, and later fine-tune it when most things are working.

      Another aspect to consider: The stm8 port uses the tree-decomposition-based register allocator. It has never been used with that many registers, and might be too slow for 15. In that case the old register allocator (what mcs51 uses and what z80 uses when specifying --oldralloc) might be a better choice.

      Philipp

       
  • htio

    htio - 2014-11-15

    yeh its a 8-bit processor and I don't think they are interchangeable, but they are sometimes combine to give an address, so there are 7 pairs of them but no arithmetic operation can be perform using the combine register. (Eg. reg1 and reg2 combine to index1, and give a address location but you cant use index1 to do any arithmetic operation )

    Thanks,
    Htio

     

    Last edit: htio 2014-11-15
  • htio

    htio - 2014-11-15

    The oldralloc is not as optimize compare to the tree-decomposition allocator right ?

     
    • Philipp Klaus Krause

      Yes. And the tree-decomposition allocator is affected by --max-allocs-per-node, so you can adjust the compilation speed vs. optimization trade-off.

      Philipp

       
      • htio

        htio - 2014-11-15

        ok, the instruction mem that goes with this processor is small 4k byte max (only 4k lines of assembly), I think i'll be going with the optimization, so.. for the case of 15 register will it take like hours to compile like say 4-5k lines of C code if I use the tree decomposition allocator?

        Thanks,
        Htio

         

        Last edit: htio 2014-11-15

Log in to post a comment.