#2090 printf_fast("%05u..",xx) cause corrupt CPU register data

closed-fixed
MCS51
5
2013-12-27
2012-10-13
Sergey
No

R0 - R2, R5, R6 are corrupted after printf_fast call.
Option -all-calee-saves on

Discussion

  • Sergey

    Sergey - 2012-10-13
    • priority: 5 --> 6
     
  • Sergey

    Sergey - 2012-10-13

    simple demo, refined

     
  • Maarten Brock

    Maarten Brock - 2012-10-13

    If you want to use --all-callee-saves then you must recompile the whole library. And several assembly implemented functions like printf_fast will not work. So they probably should either warn about that or be double implemented.

     
  • Maarten Brock

    Maarten Brock - 2012-10-13
    • labels: 379622 --> Run Time Library
    • priority: 6 --> 5
     
  • Sergey

    Sergey - 2012-10-13

    Yes, I understand.
    But HOW do it ?
    I easy can made appropriate modifications myself.

    p.s. By my opinion, register(s) saving/restore - must be immanent option for any standard subroutine, simply to avoid code repeating around each call.

     
  • Maarten Brock

    Maarten Brock - 2012-10-13

    Using the default caller-saves is not repeating the same code around each call. Register pressure depends as much on the caller as it does on the callee. It very much depends on the code whether caller-saves or callee-saves is the most optimal.

    Further, the default caller-saves is regression tested every day, but callee-saves sees hardly any testing.

     
  • Sergey

    Sergey - 2012-10-13

    Yes, You are right, caller-saves may be more efficient by execution time, if amount of caller's register-based variables are small (more precisely, less, than callee).
    But it clearly not too optimal solution in such terms, as total code size, and reliability.

     
  • Maarten Brock

    Maarten Brock - 2013-12-27

    Added --all-callee-saves to generated .optsdcc line so the linker will error on mixed usage in SDCC 3.3.2 #8929. Also generate predefined macro __SDCC_ALL_CALLEE_SAVES so source can check for this.

     
  • Maarten Brock

    Maarten Brock - 2013-12-27
    • status: open --> closed-fixed
    • assigned_to: Maarten Brock
    • Category: --> MCS51
     

Log in to post a comment.