#2290 sdasstm8 produces bad BRES & BSET opcodes

closed-fixed
Ben Shi
BRES BSET (1)
sdas
7
2014-08-19
2014-08-16
JerryW
No

Discovered reproducible problem with sdasstm8 assembler.
Problem exists for both BSET and BRES instructions.

I have not tested but suspect there's potentially a similar problem
with the BCPL (bit complement) instruction.

I found the problem - fixed it - and tested the fix...

see attachments.

2 Attachments

Related

Bugs: #2290

Discussion

  • Ben Shi
    Ben Shi
    2014-08-16

    I suppose you are using a quite old version of sdcc / sdas? This bug was already fixed in rev8988.

    https://sourceforge.net/p/sdcc/code/8988

    I tried the newest sdasstm8 (rev9059) with your Test_BRES_BSET_Orig.s.

    sdasstm8 Test_BRES_BSET_Orig.s -l

    And got the right result as you expected in your BSET_BRES_ProblemReport.txt.

      000002 72 10 50 0F      [ 1]   13         BSET    0x500f, #0      ;
      000006 72 12 50 0F      [ 1]   14         BSET    0x500f, #1      ;
      00000A 72 14 50 0F      [ 1]   15         BSET    0x500f, #2      ;
      00000E 72 16 50 0F      [ 1]   16         BSET    0x500f, #3      ;
      000012 72 18 50 0F      [ 1]   17         BSET    0x500f, #4      ;
      000016 72 1A 50 0F      [ 1]   18         BSET    0x500f, #5      ;
      00001A 72 1C 50 0F      [ 1]   19         BSET    0x500f, #6      ;
      00001E 72 1E 50 0F      [ 1]   20         BSET    0x500f, #7      ;
                                     21
      000022 72 11 50 0F      [ 1]   22         BRES    0x500f, #0      ;
      000026 72 13 50 0F      [ 1]   23         BRES    0x500f, #1      ;
      00002A 72 15 50 0F      [ 1]   24         BRES    0x500f, #2      ;
      00002E 72 17 50 0F      [ 1]   25         BRES    0x500f, #3      ;
      000032 72 19 50 0F      [ 1]   26         BRES    0x500f, #4      ;
      000036 72 1B 50 0F      [ 1]   27         BRES    0x500f, #5      ;
      00003A 72 1D 50 0F      [ 1]   28         BRES    0x500f, #6      ;
      00003E 72 1F 50 0F      [ 1]   29         BRES    0x500f, #7      ;
    

    What's more, I found that BCPL / BCCM were also right.

     
  • Ben Shi
    Ben Shi
    2014-08-16

    This bug did exist in the SDCC-3.4.0 release, and we have made many improvements to the stm8 port since then, including this bug fix.

    You are suggested to try latest SDCC on the snapshot build page, or build from the source.

    sdcc.sourceforge.net/snap.php
    svn checkout svn://svn.code.sf.net/p/sdcc/code/trunk sdcc-code

     
  • Maarten Brock
    Maarten Brock
    2014-08-16

    Ben,

    When you find a bug has already been fixed please mark it as closed (and
    assign it to yourself). There's no point in keeping it around.

    Maarten

    This bug did exist in the SDCC-3.4.0 release, and we have made many
    improvements to the stm8 port since then, including this bug fix.

    You are suggested to try latest SDCC on the snapshot build page, or build
    from the source.

    sdcc.sourceforge.net/snap.php
    svn checkout svn://svn.code.sf.net/p/sdcc/code/trunk sdcc-code


    [bugs:#2290] sdasstm8 produces bad BRES & BSET opcodes

    Status: open
    Labels: BRES BSET
    Created: Sat Aug 16, 2014 02:59 AM UTC by JerryW
    Last Updated: Sat Aug 16, 2014 08:24 AM UTC
    Owner: nobody

    Discovered reproducible problem with sdasstm8 assembler.
    Problem exists for both BSET and BRES instructions.

    I have not tested but suspect there's potentially a similar problem
    with the BCPL (bit complement) instruction.

    I found the problem - fixed it - and tested the fix...

    see attachments.


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/sdcc/bugs/2290/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #2290

  • Ben Shi
    Ben Shi
    2014-08-16

    • assigned_to: Ben Shi
    • Priority: 3 --> 7
     
  • Ben Shi
    Ben Shi
    2014-08-16

    I will close it after JerryW confirms that, or several days later if not.

     
    • JerryW
      JerryW
      2014-08-18

      Yes, I am using the 3.4.0 release, I've confirmed the fix is present and works in the 8988 build.

      I have a follow up question. In the course of testing/verifying my C code after the assembler fixes, I noticed that PH optimization was targeting only the least and most significant bits (PH 11-0, 11-7, 12-0 & 12-7) for BRES/BSET.

      Any particular reason for not going after the mid-field bits?

      Thanks for all the good work!

      Jerry

      P.S.
      I've also been working on some STM8 assembly floating point routines.
      So far about a 10x improvement over the standard library stuff.
      Any suggestions on where might be a good location to share them?
      They'll likely need some extensions if we want some degree of IEEE compliance...

       
  • Ben Shi
    Ben Shi
    2014-08-19

    • status: open --> closed-fixed
     
  • Ben Shi
    Ben Shi
    2014-08-19

    I thought for the bres/bset, maybe LSB & MSB appear more frequently, but others bits should also be optimized if space/time cost can be saved.

    You are highly welcome to create patch tickets on
    http://sourceforge.net/p/sdcc/patches/ for either your floating point improvement or new PH rules (regarding bset/bres).

    I will close this bug, and please send any more suggestions to the mail list sdcc-user and sdcc-devel.