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

Close

#24 Fix for shiftL2Left2Result

closed-accepted
None
5
2004-10-01
2004-09-21
Raphael Neider
No

While reading the codegeneration functions in the PIC16
port
for various shift operations, I found one bug and a few
minor
inefficiencies.

gen.c:8084 had a wrong literal 0xF0 instead of 0x0F
This would create wrong results for
i << 5 with an int i.

gen.c:8218 reads the sign bit after some rotations from
the wrong
place. Bit 15 from the left operand is only once
rotated into
result+offr<bit 0>
This would cause "i >> 6" to fail for signed ints
i, but the
compiler does not erach this point (see my bugreport
#1032131).

Minor improvements are:

gen.c:7728ff one instruction can be saved by replacing two
RLCFW by one RLNCWF as the carry bit is ignored
afterwards

gen.c:7744ff (same thing)

gen.c:7858ff one instruction can be saved by not
clearing the
carry bit explicitly but replacing RRCF by RRNCF and
clearing bit 0 in the AND instruction above

Later (in case 6:) another instruction can be
saved by
replacing RLCF with RLNCF and thus keeping the carry
bit in the register (also have to modify the AND
mask above)

gen.c:8354ff shiftLLong
The if-statements (size >= something) allowed for
access
beyond the size of the result operand (via the MOVWF
instructions with MSBxx+offr) --- though these cases
would only occur for queer result sizes (e.g. 3).

Patch to be applied in src/pic16 with -p0.

BTW: These routines have certainly been a good deal of
work, thank you for your engagement!

Raphael Neider

Discussion

  • Raphael Neider
    Raphael Neider
    2004-09-21

    Patch for fixing the issues mentioned above.

     
    Attachments
  • Vangelis Rokas
    Vangelis Rokas
    2004-09-24

    • assigned_to: nobody --> vrokas
    • status: open --> pending-accepted
     
  • Vangelis Rokas
    Vangelis Rokas
    2004-09-24

    Logged In: YES
    user_id=770505

    Please upload again the patch file adding
    options -cp when running diff

     
  • Raphael Neider
    Raphael Neider
    2004-09-24

    Logged In: YES
    user_id=1115835

    I just uploaded the new version of the patch.

    Raphael

     
  • Raphael Neider
    Raphael Neider
    2004-09-24

    • status: pending-accepted --> open-accepted
     
  • Raphael Neider
    Raphael Neider
    2004-09-24

    New version patching the same things

     
    Attachments
  • Vangelis Rokas
    Vangelis Rokas
    2004-10-01

    Logged In: YES
    user_id=770505

    Patch applied successfully.
    SDCC version 2.4.5 #851

     
  • Vangelis Rokas
    Vangelis Rokas
    2004-10-01

    • status: open-accepted --> closed-accepted