Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Overflow Flag Reply to this message
Posted byJonemaan
Posted on09/17/07 09:00 AM



> I'm Googling and I can't find much information about whether this is right...
> has anyone done this before? What method did you use for the carry, half-carry
> and overflow flags? (Not too bothered about half carry since I working on 68000,
> but just curious for Z80). Noticed further down the board something was
> mentioned about xoring all three for half carry?
>

You didn't clearly mention which CPU you're having problems with, but I assume it's the Z80. Mine passes ZEXALL, this is what I did:

for 8-bit add/adc, sub/sbc (it's similar with 16-bit opcodes)
A=accumulator
d=data to be added/subtracted, excluding carry flag
r=result after calculation

carry: simply A>r for add, A<r for sub (or if r>8bit: r>>8&1)
half carry: like you said it's (r^A^d)&0x10
overflow: ((A^r)&(d^r))>>5&4 for add, ((A^d)&(A^r))>>5&4 for sub


-
Entire Thread
Subject  Posted byPosted On
*Overflow Flag  finaldave09/12/07 03:18 AM
..Re: Overflow Flag  Jonemaan09/17/07 09:00 AM
..*Re: Overflow Flag  finaldave09/19/07 06:19 PM