[Coco] 6809 CC Reg Overflow bit
Neil Cherry
ncherry at linuxha.com
Tue Nov 6 19:10:48 EST 2018
On 11/06/2018 06:40 PM, Neil Cherry wrote:
> On 11/06/2018 06:24 PM, Gene Heskett wrote:
>> On Tuesday 06 November 2018 17:58:22 Brendan Donahe wrote:
>>
>>> Ok, dumb followup question then - if those 100s and 200s are decimal
>>> (I see no $) then why is this an overflow? Is overflow for a signed
>>> byte?
>>
>> I think so, v is set (I think) if the result is >127, for 2's complement
>> math. This also explains the need for the SEX, or sign extend
>> instruction, something the C compiler goes crazy with.
>
> I think I had it wrong:
>
>
> .a400
> 0400 0000 NEG $00 lda #100
> 0402 0000 NEG $00 adda #100
> 0404 0000 NEG $00 adda #100
> 0406 0000 NEG $00 nop
> 0407 0000 NEG $00 nop
> 0408 0000 NEG $00 .
> .r
> X=0000 Y=0000 U=0000 S=0400 A=00 B=00 D=00 C=00
> P=0400 LDA #$64
> .p
> X=0000 Y=0000 U=0000 S=0400 A=64 B=00 D=00 C=00
> P=0402 ADDA #$64
> .p
> X=0000 Y=0000 U=0000 S=0400 A=C8 B=00 D=00 C=0A
> P=0404 ADDA #$64
> .p
> X=0000 Y=0000 U=0000 S=0400 A=2C B=00 D=00 C=01
> P=0406 NOP
> .
>
> This is from the sbc09 emulator, I grabbed a copy and tossed it on my
> Linux box. C=0A (Negative set, Overflow set) then C=01 (Negative cleared,
> Overflow cleared).
>
> Sorry too many asm languages. :-)
>
One more note from the Motorola M6809 Microprocessor Programming Manual:
1.10.1.4 Overflow (V), Bit 1. This bit is used to indicate that the previous
operation caused a signed arithmetic overflow.
I hope that helps clear this up.
--
Linux Home Automation Neil Cherry ncherry at linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies
More information about the Coco
mailing list