Carry flag macros for C

Материал из fidoman.ru
Версия от 18:22, 19 декабря 2021; Sergey (обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)

Macros of inline functions for integer addition and subtracion with respect of carry flag

bool cadd(lvalue, rvalue1, rvalue2) // rvalue1+rvalue2 -> lvalue, returns true if there was carry

bool csub(lvalue, rvalue1, rvalue2) // rvalue1-rvalue2 -> lvalue, returns true if there was borrow

bool cadc(lvalue, rvalue1, rvalue2, rvalue_c) // rvalue1+rvalue2+c -> lvalue, returns true if there was carry

bool csbb(lvalue, rvalue1, rvalue2, rvalue_b) // rvalue1-rvalue2-b -> lvalue, returns true if there was borrow

And also for shift operations

bool rlc // rotate through carry

bool rrc

bool shl // shift with outmove bit to carry

bool shr

bool rol // rolling with outmove (duplicate bit to carry and to bit on side from which bits are moved)

bool ror