[Coco] Apparent discrepancy between MAME and XRoar re: SBCB instruction

Pierre Sarrazin sarrazip at sarrazip.com
Tue Oct 17 19:22:57 EDT 2017


Hi folks,

I seem to have found a difference in the way the SBCB instruction
executes on MAME (0.158) and XRoar (0.34.7), unless I'm doing something
wrong without realizing it.

I would like to know which emulator is right. I don't have easy access
to my real CoCo, so I wondered if anyone here could run the following
program and tell me which number 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.158, it's 7 while on XRoar, 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 XRoar set it to 0.

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

A test on the latest MAME would also be useful.

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

I also prepared a disk image with the Basic program on it:
http://sarrazip.com/dev/sbc.dsk

Thanks.

-- 
Pierre Sarrazin <sarrazip @ sarrazip . com>


More information about the Coco mailing list