Missing register info in CDB file

BLRCalvin
2008-07-28
2013-03-12
  • BLRCalvin
    BLRCalvin
    2008-07-28

    Hello,

    I am using mcs51 port with SDCC 2.8 and observed that the register list for the variable
    "value1" is empty in the .cdb file.

    -------------Example Begin-------------------------------------------
    #include <stdio.h>

    void puthex2num(unsigned char num){  }

    unsigned int GetSFRValue(int x)
    {
        return (x+0xF000);   //This code is made simple for the sake of example
    }

    void main(void)
    {
      unsigned int i; unsigned char value1 = 0;
     
      for(i=0; i<20; i++){
            value1 = (unsigned char) GetSFRValue(i);
          puthex2num(value1);
      }
     
    }
    -------------Example End -------------------------------------------

    commandline options used:
    ------------------------
    sdcc -mmcs51 main.c --debug --nogcse --nooverlay --noinduction --nojtbound --noinvariant
    --no-peep --nolabelopt -o output.hex

    output.cdb
    -----------
    M:main
    F:G$puthex2num$0$0({2}DF,SV:S),C,0,0,0,0,0
    F:G$GetSFRValue$0$0({2}DF,SI:U),C,0,0,0,0,0
    F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0
    S:Lputhex2num$num$1$1({1}SC:U),R,0,0,[]
    S:LGetSFRValue$x$1$1({2}SI:S),R,0,0,[r2,r3]
    S:Lmain$i$1$1({2}SI:U),R,0,0,[r2,r3]
    S:Lmain$value1$1$1({1}SC:U),R,0,0,[] -------------> The register list is empty.

    Also, in the assembly file, in the allocation info of the function main, it is said that the variable "value1" is allocated to registers but further no info on the registers.

    I would like this specific problem to get to your notice. Any help is appreciated.

    Thanks & Regards,
    Raghu.

     
    • Maarten Brock
      Maarten Brock
      2008-07-30

      Because value1 is the result of the first call and only used immediately after as the first parameter to the second call it probably only stays in DPL which is not recorded.

       
    • BLRCalvin
      BLRCalvin
      2008-07-30

      Below is the assembly code generated for function "main". The return value of GetSFRValue()is moved to registers r4, r5 and then the contents of r4 are again moved to DPL just before the function call to puthex2num(). So, I believe "value1" should be reported as r4 in CDB file.

      ;------------------------------------------------------------
      ;Allocation info for local variables in function 'main'
      ;------------------------------------------------------------
      ;i                         Allocated to registers r2 r3
      ;value1                    Allocated to registers
      ;------------------------------------------------------------
          G$main$0$0 ==.
          C$main.c$29$1$1 ==.
      ;    main.c:29: void main(void)
      ;    -----------------------------------------
      ;     function main
      ;    -----------------------------------------
      _main:
          C$main.c$34$1$1 ==.
      ;    main.c:34: for(i=0; i<20; i++)
          mov    r2,#0x00
          mov    r3,#0x00
      00107$:
      00101$:
          clr    c
          mov    a,r2
          subb    a,#0x14
          mov    a,r3
          subb    a,#0x00
          jc    00108$
          ljmp    00105$
      00108$:
      00102$:
          C$main.c$36$2$2 ==.
      ;    main.c:36: value1 = (unsigned char) GetSFRValue(i);
          mov    dpl,r2
          mov    dph,r3
          push    ar2
          push    ar3
          lcall    _GetSFRValue
          mov    r4,dpl    ------> The return value is moved to registers r4, r5  
          mov    r5,dph
          pop    ar3
          pop    ar2
          mov    dpl,r4    -------> The contents in register r4 are moved to DPL as param.
          C$main.c$37$2$2 ==.
      ;    main.c:37: puthex2num(value1);
          push    ar2
          push    ar3
          lcall    _puthex2num
          pop    ar3
          pop    ar2
      00103$:
          C$main.c$34$1$1 ==.
      ;    main.c:34: for(i=0; i<20; i++)
          inc    r2
          cjne    r2,#0x00,00101$
          inc    r3
          ljmp    00101$
      00104$:
      00105$:
          C$main.c$40$1$1 ==.
          XG$main$0$0 ==.
          ret