Carry flag macros for C: различия между версиями

Материал из fidoman.ru
(Новая страница: «== Macros of inline functions for integer addition and subtracion with respect of carry flag == bool cadd(lvalue, rvalue1, rvalue2) // rvalue1+rvalue2 -> lvalue,...»)
 
 
Строка 2: Строка 2:
  
 
bool cadd(lvalue, rvalue1, rvalue2) // rvalue1+rvalue2 -> lvalue, returns true if there was carry
 
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 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 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
 
bool csbb(lvalue, rvalue1, rvalue2, rvalue_b) // rvalue1-rvalue2-b -> lvalue, returns true if there was borrow
  
Строка 9: Строка 12:
  
 
bool rlc // rotate through carry
 
bool rlc // rotate through carry
 +
 
bool rrc
 
bool rrc
 +
 
bool shl // shift with outmove bit to carry
 
bool shl // shift with outmove bit to carry
 +
 
bool shr  
 
bool shr  
  
 
bool rol // rolling with outmove (duplicate bit to carry and to bit on side from which bits are moved)
 
bool rol // rolling with outmove (duplicate bit to carry and to bit on side from which bits are moved)
 +
 
bool ror
 
bool ror

Текущая версия на 18:22, 19 декабря 2021

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