> > 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
> > 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)
> d=data to be added/subtracted, excluding carry flag
> r=result after calculation
> carry: simply A>r for add, A8bit: 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
Cool :-) I came up with someting like (A^r)&(d^r), but that's really interesting that subtraction is similar as well but just with the A d r switched round... very very cool!
Newsdee's Love, Glory, and Discussion Boards