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

William Astle lost at l-w.ca
Tue Oct 17 19:41:00 EDT 2017


V should not be set in that case. V is applicable only to 2's complement 
signed results. Since your problem amounts to "0 - (-1) - 1" or "0 + 1 - 
1", there is clearly no overflow.

It sounds like a bright spark somewhere confused the 6809 V flag with 
carry. Or decided that it should be inverted because the carry flag is 
inverted after subtraction (something most CPUs don't do). Or maybe 
confused the 6809 overflow with what some other CPUs apparently call 
"overflow" but is really equivalent to the 6809 carry.

Either way, your actual arithmetic problem there should not overflow.

On 2017-10-17 05:22 PM, Pierre Sarrazin wrote:
> 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.
> 



More information about the Coco mailing list