Menu ▾ ▴

#330 PIC18 numeric destination operand incorrectly updates bank flag

None
open
nobody
5
4 days ago
4 days ago
No

For PIC18 instructions using INSN_CLASS_OPWFA8, gpasm handles symbolic destination operands (W / F) correctly, but numeric destination operands (0 / 1) update insn_flags.bank instead of insn_flags.dest.

As a result, with strict level 2, valid instructions such as:

    processor 18f452
    radix hex

    movf    0x20, 0, 0
    incf    0x20, 1, 0
    infsnz  0x20, 1, 0

    end

are incorrectly rejected with:

Error[1502] destination not selected

The generated instruction encoding itself is not changed by this fix; the problem is the internal destination-selection bookkeeping used by diagnostics and strict checking.

The fix is a one-line change in gpasm/directive.c:

  • insn_flags.bank = (d == W) ? IFLAG_DEST_SEL_WREG : IFLAG_DEST_SEL_FILE;
  • insn_flags.dest = (d == W) ? IFLAG_DEST_SEL_WREG : IFLAG_DEST_SEL_FILE;

A regression test is included and is run with -S 2, since the bug is exposed at strict level 2.

Tested against a clean gputils r1333 working copy. The full gpasm regression suite passes after the change.

1 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel