#598 #pragma EXCLUDE doesn't work as expected

closed-fixed
1
2013-05-25
2003-10-02
No

// There seems to be an off-by-one error with the
#pragma EXCLUDE.
// If f.e. EXCLUDE acc,b is specified then only "push
acc" is omitted
// while "push b" is still generated.

volatile unsigned char i,j;

void test_no_pragma(void) interrupt 1 { i++; }

#pragma SAVE
#pragma EXCLUDE acc
void test_no_acc(void) interrupt 2 { i++; }
#pragma RESTORE

#pragma SAVE
#pragma EXCLUDE acc,b
void test_no_acc_b(void) interrupt 3 { i++; }
#pragma RESTORE

#pragma SAVE
#pragma EXCLUDE acc,b,dpl
void test_no_acc_b_dpl(void) interrupt 4 { i++; }
#pragma RESTORE

#pragma SAVE
#pragma EXCLUDE psw
// INCrement doesn't touch flags, so omitting psw
handling would be ok.
// I'm silently hiding a feature request here;) I
assume this feature
// would be rarely used...
void test_no_psw(void) interrupt 5 { i++; j=1; }
#pragma RESTORE

Discussion

  • Erik Petrich

    Erik Petrich - 2003-10-09
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
     
  • Erik Petrich

    Erik Petrich - 2003-10-09

    Logged In: YES
    user_id=635249

    The bug is fixed in src/SDCCmain.c 1.175.

    The EXCLUDE psw feature request will wait for another session.

     
  • Erik Petrich

    Erik Petrich - 2004-02-29

    Logged In: YES
    user_id=635249

    "#pramga exclude" is almost obsolete with the changes noted
    in ChangeLog 1.656. The mcs51 port now analyzes which
    registers are modiied (including side-effects in the psw)
    and saves only what is needed. "#pragma exclude psw" is
    automagic. Check this out:

    volatile unsigned char i,j;
    volatile unsigned int k;

    void test_auto_exclude1(void) interrupt 1 {
    i++; j=1;
    }

    void test_auto_exclude2(void) interrupt 2 {
    k++;
    }

    _test_auto_exclude1:
    ar2 = 0x02
    ar3 = 0x03
    ar4 = 0x04
    ar5 = 0x05
    ar6 = 0x06
    ar7 = 0x07
    ar0 = 0x00
    ar1 = 0x01
    ;intr2.c:5: i++; j=1;
    ; genPlus
    ; genPlusIncr
    inc _i
    ; genAssign
    mov _j,#0x01
    00101$:
    reti
    ; eliminated unneeded push/pop psw
    ; eliminated unneeded push/pop dpl
    ; eliminated unneeded push/pop dph
    ; eliminated unneeded push/pop b
    ; eliminated unneeded push/pop acc
    _test_auto_exclude2:
    push acc
    push psw
    mov psw,#0x00
    ;intr2.c:9: k++;
    ; genPlus
    ; genPlusIncr
    inc _k
    clr a
    cjne a,_k,00103$
    inc (_k + 1)
    00103$:
    00101$:
    pop psw
    pop acc
    reti
    ; eliminated unneeded push/pop dpl
    ; eliminated unneeded push/pop dph
    ; eliminated unneeded push/pop b

    (cjne modifies carry, so push/pop psw was retained in second
    function)

     

Log in to post a comment.