Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Another way to put it is that in SBC context the carry provides for the bit required to turn ones' complement into two's complement (all bits flipped + 1). If it's clear, we fall short by one (so we remain in ones' complement, missing the "+1" part), which makes for a perfect implementation of a borrow. Since SBC is essentially ADC with the invers of the operand (ones' complement) this applies in general (not just for negative values).

(So, technically, the carry is like a ones' complement / two's complement switch. And this is also all we need to implement a borrow in two's complement math.)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: