Re: A83: SBC


[Prev][Next][Index][Thread]

Re: A83: SBC




Thanks Linus...I understand, but kinda...

Could you (or anyone) give me an example.  Like take two numbers and
subtract them using SUB, then using SBC.  Thanks.

James.

> 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


Follow-Ups: