Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1125 signedness miscalculation

closed-fixed
Bernhard Held
5
2013-05-25
2006-05-23
Stas Sergeev
No

Hi.

The following program (attached) doesnt work
properly:
---
struct {
unsigned char a;
} st = { 0xff };
signed char c = -1;

unsigned char main()
{
st.a += c;
return (st.a > 8);
}
---

It returns 0, but I'd expect 1 to be returned.
The asm looks like this:
---
; Peephole 159 avoided xrl during execution
mov a,#(0x08 ^ 0x80)
mov b,r2
xrl b,#0x80
subb a,b
---
which looks wrong for the unsigned evaluations.

Discussion

  • Stas Sergeev
    Stas Sergeev
    2006-05-23

    a test-case

     
    Attachments
  • Bernhard Held
    Bernhard Held
    2006-05-27

    Logged In: YES
    user_id=203539

    Fixed in sdcc rev 4195.

    Thanks for the perfectly stripped down source! This is
    always of great help.

     
  • Bernhard Held
    Bernhard Held
    2006-05-27

    • milestone: --> fixed
    • assigned_to: nobody --> bernhardheld
    • status: open --> closed-fixed