jefftranter / 6502

Code for the 6502 microprocessor, mostly for the Replica 1 computer.
298 stars 66 forks source link

JMON srecord end address issue #14

Closed w4jbm closed 3 years ago

w4jbm commented 3 years ago

JMON allows creation of Moto S record dumps. The current source will not do complete dumps for some specified ranges.

Specifying either $2000-$201F or $2000-$2020 will both dump up to $201F and stop.

Specifying $2000-$22FF will dump $2000-$21FF while specifying $2000-$2300 will dump $2000-$22FF.

Part of the issue seems to be that each record contains bytesPerLine number of bytes. This means that the count can increment past the specified end address prior to checking. Because of this, doing the comparison as a pair of 8-bit compares instead of a full 16-bit magnitude comparison can cause problems.

The pointer to the next address to be dumped is also incremented prior to checking if we are at the end, so the proper test is for 'less than or equal to' instead of just 'less than'.

The current code at line 1925 in jmon.s is:

        lda     ADDR+1          ; if address < endAddress, go back and continue
        cmp     EH
        bmi     writes1
        lda     ADDR
        cmp     EL
        bmi     writes1

I have replaced this with the following:

        lda     ADDR+1          ; if address <= endAddress, go back and continue
        cmp     EH
        bne     @tstaddr
        lda     ADDR
        cmp     EL
@tstaddr:
        bcc     writes1
        beq     writes1

This still dumps in blocks of bytesPerLine but does catch the equal comparison so that something like $2000-$2100 will end up dumping to $211F (which is 15 bytes long instead of ending 1 byte short at $20FF as previously happened).

jefftranter commented 3 years ago

Change commited. Thanks.