Re: A83: SBC
[Prev][Next][Index][Thread]
Re: A83: SBC
Normally, SBC and ADC are used when adding bigger numbers than 8-bit ones.
E.g. if two three byte numbers should be added, you first add the least
significant bytes. This addition sets the carry flag if the additiongot past
ff. Next, you add the middle bytes _together with the carry flag_. If there
was a carry, that carry will be added! AND the carry flag will be updated, so
that you can add the most significant byte directly (with adc of course).
When sgs designed their z80, they ran out of instruction codes. They had to
remove some instructions, and they thought that 16 bit subtraction didn't need
two separate instructions (sub and sbc). So they removed sub, meaning that the
programmer would have to clear the carry flag manually to do a sub. This is
done with e.g. "or a".
There's still both add and adc, though.
Linus
On 15-Jun-98, James Matthews wrote:
>I know SBC is a subtract with carry, but what does that mean? :)
>In Ian's FP program it says "SBC hl,bc", so that's:
>hl - bc - (carry bit 0)
>What does that do differently?
>Thanks.
>James.
References:
- A83: SBC
- From: "James Matthews" <matthews@tkb.att.ne.jp>