Musashi icon indicating copy to clipboard operation
Musashi copied to clipboard

Issues with NBCD instruction

Open dirkwhoffmann opened this issue 6 years ago • 0 comments

The implementation of NBCD doesn’t seem to be correct.

To verify this instruction, I’ve written four test cases:

https://github.com/dirkwhoffmann/vAmigaTS/tree/master/CPU/NBCD

nbcd1

Draws two 16 x 16 squares. In each square, the NBCD command is run for all 256 possible source values. The left square has the X flag cleared and the right square set. Each 8 x 8 pixel box shows the bit pattern of value computed by the instruction under test.

nbcd2

Displays the value of the N flag after NBCD has been executed.

nbcd3

Displays the value of the V flag after NBCD has been executed.

nbcd4

Displays the value of the X,Z, and V flag after NBCD has been executed.

Here are the results:

Musashi (vAmiga):

Bildschirmfoto 2019-12-25 um 10 18 34

A real Amiga (A500+ 🥰):

nbcd1_A500+

The left image (NBCD executed with X = 0) seems to be correct. The right image differs.

The flags show discrepancies, too:

Musashi (vAmiga):

Bildschirmfoto 2019-12-25 um 10 22 17 Bildschirmfoto 2019-12-25 um 10 21 15 Bildschirmfoto 2019-12-25 um 10 21 39

A500+:

nbcd2_A500+ nbcd3_A500+ nbcd4_A500+

I've also run the test cases in UAE. As far as I could see, UAE does it right. I didn't look into the UAE code yet, but it might help to fix the instruction.

dirkwhoffmann avatar Dec 25 '19 09:12 dirkwhoffmann