// The OS/K Team licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #include //----------------------------------------------------------------------------// IMPL_START_3(krotl) { ulong tmp = v1; v1 = v2; v2 = v3; v3 = tmp; } IMPL_OUT_3; IMPL_START_3(krotr) { ulong tmp = v3; v3 = v2; v2 = v1; v1 = tmp; } IMPL_OUT_3; //----------------------------------------------------------------------------// #define K_IMPL_ALU(name, expr) \ IMPL_START_3(k##name) \ { \ v1 = (expr); \ } \ IMPL_OUT K_IMPL_ALU(or, v2 | v3); K_IMPL_ALU(and, v2 & v3); K_IMPL_ALU(xor, v2 ^ v3); K_IMPL_ALU(nor, ~(v2 | v3)); K_IMPL_ALU(orn, v2 | ~v3); K_IMPL_ALU(nand, ~(v2 & v3)); K_IMPL_ALU(andn, v2 & ~v3); K_IMPL_ALU(xnor, ~(v2 ^ v3)); K_IMPL_ALU(xorn, v2 ^ ~v3); K_IMPL_ALU(shl, v2 << v3); K_IMPL_ALU(shr, v2 >> v3); K_IMPL_ALU(add, v2 + v3); K_IMPL_ALU(adc, v2 + v3 + !!(flg&CF)); K_IMPL_ALU(ado, v2 + v3 + !!(flg&OF)); K_IMPL_ALU(sub, v2 - v3); K_IMPL_ALU(sbb, v2 - v3 - !!(flg&CF)); K_IMPL_ALU(sbo, v2 - v3 - !!(flg&OF)); K_IMPL_ALU(mul, v2 * v3); K_IMPL_ALU(div, v2 / v3); K_IMPL_ALU(rem, v2 % v3); //----------------------------------------------------------------------------// IMPL_START_3(ksal) { long w2 = v2; long w3 = v3; w2 <<= w3; v1 = (ulong)w2; } IMPL_OUT; IMPL_START_3(ksar) { long w2 = v2; long w3 = v3; w2 >>= w3; v1 = (ulong)w2; } IMPL_OUT; //----------------------------------------------------------------------------//