public static (BitVecExpr result, BoolExpr cf, BoolExpr of, BoolExpr af) Substract( BitVecExpr a, BitVecExpr b, BoolExpr carry, Context ctx ) { if (carry.IsFalse) { return(Substract(a, b, ctx)); } uint nBits = a.SortSize; BitVecExpr bv0_1bit = ctx.MkBV(0, 1); BitVecExpr bv1_1bit = ctx.MkBV(1, 1); BitVecExpr ax = ctx.MkConcat(bv0_1bit, a); BitVecExpr bx = ctx.MkConcat(bv0_1bit, b); BitVecExpr bx2 = ctx.MkBVAdd(bx, ctx.MkITE(carry, ctx.MkBV(1, nBits + 1), ctx.MkBV(0, nBits + 1)) as BitVecExpr); BitVecExpr rx = ctx.MkBVSub(ax, bx2); BitVecExpr result = ctx.MkExtract(nBits - 1, 0, rx); BoolExpr cf = ToolsFlags.Create_CF_Sub(ax, bx2, nBits, ctx); BoolExpr of = ToolsFlags.Create_OF_Sub(ax, bx2, nBits, ctx); BoolExpr af = ToolsFlags.Create_AF_Sub(ax, bx2, ctx); return(result : result, cf : cf, of : of, af : af); }
public static (BitVecExpr result, BoolExpr cf, BoolExpr of, BoolExpr af) Substract( BitVecExpr a, BitVecExpr b, Context ctx) { uint nBits = a.SortSize; BitVecExpr result = ctx.MkBVSub(a, b); BoolExpr cf = ToolsFlags.Create_CF_Sub(a, b, nBits, ctx); BoolExpr of = ToolsFlags.Create_OF_Sub(a, b, nBits, ctx); BoolExpr af = ToolsFlags.Create_AF_Sub(a, b, ctx); return(result : result, cf : cf, of : of, af : af); }