#1125 signedness miscalculation

closed-fixed
5
2013-05-25
2006-05-23
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

     
  • 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
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks