Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
06719 Core Minor Always Oct 18, 2017, 00:55 Oct 18, 2017, 22:25
Tester star2root View Status Public Platform MAME (Self-compiled)
Assigned To hap Resolution Fixed OS
Status [?] Resolved Driver
Version 0.187 Fixed in Version 0.191 Build
Fixed in Git Commit Github Pull Request #
Summary 06719: coco12, coco3, other 6809?: SBCB instruction returns the wrong result
Description Run the following program and look at the number that appears on the line before the final OK prompt (on the 32x16 screen).

10 DATA5F,1C,00,1A,01,C2,FF
20 DATA34,01,35,02,B7,04,00,39
30 FORI=0TO14:READH$
40 POKE&H3800+I,VAL("&H"+H$)
50 NEXT
60 CLS:PRINT
70 EXEC&H3800
80 PRINTPEEK(1024)AND15

On MAME 0.187, it's 7 while on the physical machine, it's 5. This value shows the N, Z,
V and C flags that result from the SBCB instruction. The two values mean
that MAME's SBCB set the V (overflow) flag to 1, while the physical machine set it to 0.

I also tested on MAME 0.140, and it gave 5, interestingly.

The assembly source is the following:

        org $3800
start
        clrb
        andcc #$00 ; clear all flags
        orcc #$01 ; set carry
        sbcb #$FF ; $00 - $ff - 1 = $00
        pshs cc
        puls a
        sta $400 ; store resulting CC on 32x16 screen
        rts
        end start

It can be assembled with LWTOOLS like this:
lwasm -fdecb -o sbc.bin sbc.asm

There is also a prepared a disk image with the Basic program on it:
http://sarrazip.com/dev/sbc.dsk
Steps To Reproduce Run the code in the description on the emulator.
Additional Information
Github Commit
Flags Verified with Original
Regression Version 0.148u2
Affected Sets / Systems coco12, coco3, other 6809?
Attached Files
 
Relationships
There are no relationship linked to this issue.
Notes
2
User avatar
No.14295
Tafoid
Administrator
Oct 18, 2017, 12:29
Updated regression version
Appears related to 6809 core rewrite:
https://github.com/mamedev/mame/commit/7c0baa1f6dd0ef221a89ec0f48ec91e0fe82668f
User avatar
No.14300
richardcavell
Tester
Oct 18, 2017, 15:54
The issue is that the + here should be a - :
https://github.com/mamedev/mame/blob/master/src/devices/cpu/m6809/base6x09.ops#L241

Credit goes to Pierre Sarrazin and Tim Lindner for investigating/finding this bug.