6800 instruction LSRA fails (sometimes!)


Replication: Load the attached program (bin2bcd.obj) into Sharp6800. Set a breakpoint at the problem area (BR 004C). Execute (DO 0000, and see "004C 96" as the breakpoint is hit). SS, ACCA (see "Acca 43", the expected value. SS, ACCA (see "Acca 21, the expected value). SS, ACCA (see "Acca 90", the wrong value as LSRA on $21 should result in $10. It appears perhaps that the Carry bit was erroneously shifted into the MS bit of the result. But I tried to reduce this to a smaller demonstration program and couldn't! Just loading $43 in ACCA and doing LSRA on it a few times works fine. Something to do with the rest of the program existing makes the problem happen.

file attachments


RupertAvery wrote Jan 7, 2015 at 12:27 AM

Probably caused by failure to limit to byte values. Seems to have been fixed by ANDing operand results with 0xFF.