#1578 hc08 assembler incorrectly allows move to non-direct destina

closed-fixed
Maarten Brock
hc08 port (43)
5
2013-05-25
2009-11-08
gaui
No

The hc08 cpu understands several forms of the mov command, all involving
direct (and indexed) addresses. In particular, this is allowed:

mov #number, *address

while this is not:

mov #number, address

(because it is not a direct address)

When using the second form, the compiler does not complain. It should.
What's worse, when using the second form with an address larger than
255, it cannot generate correct code (because that doesn't exist). The
programmer is not notified about this, which makes finding the bug
extremely hard.

The original bug report with example code can be found in the Debian bug tracking system
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=422599
and it still persists in sdcc SVN revision 5568

Regards
Gudjon

Discussion

  • Maarten Brock
    Maarten Brock
    2012-01-02

    Copied from the original bug report:

    > Hi,
    >
    > On Sun, Nov 08, 2009 at 09:38:32AM +0100, Gudjon I. Gudjonsson wrote:
    > > Can you please test if this bug has been fixed in the current version?
    >
    > It has not. To test this, you can do the following:
    >
    > create a file named test.asm, with in it:
    >
    > mov #18, *30
    > mov #18, 30
    > mov #18, 3000
    >
    > Then run as-hc08 -o test.asm. This creates a file called test.rel. It
    > looks like this:
    >
    > XH
    > H 1 areas 0 global symbols
    > A _CODE size 9 flags 0 addr 0
    > T 00 00 6E 12 1E 6E 12 1E 6E 12 B8
    > R 00 00 00 00
    >
    > The line starting with T shows that (at address 0), there is 3 times the
    > same 3-byte command (6e 12 xx), where xx is 1e for 30, and b8 for 3000
    > (3000 & 0xff = 0xb8a).
    >
    > If you only want to test, you don't even need to look at the output; if
    > "mov #18, 3000" compiles without errors, this bug is still present.
    > There should be an error for "mov #18, 30" as well, but it is not a big
    > problem if there isn't (it is obvious that it really means
    > "mov #18, *30", because there is no other option).
    >
    > Thanks,
    > Bas

     
  • Maarten Brock
    Maarten Brock
    2012-01-03

    Fixed in SDCC 3.1.1 #7149.

     
  • Maarten Brock
    Maarten Brock
    2012-01-03

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