1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/in/logic.c
julianb0 a42786831f
vm
2019-07-04 20:33:49 +02:00

76 lines
1.7 KiB
C

// 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 <in/instrs.h>
//----------------------------------------------------------------------------//
IMPL_START_2(not)
{
v1 = ~v2;
}
IMPL_OUT;
IMPL_START_2(test)
{
flg &= ~(CF|OF);
SET_ZSF(v1 & v2);
}
IMPL_END;
//----------------------------------------------------------------------------//
#define LOGIC_IMPL(name, op) \
IMPL_START_2(name) \
{ \
ALU_GET_SRCS(); \
v1 = op; \
} \
IMPL_OUT;
LOGIC_IMPL(and, src1 & src2);
LOGIC_IMPL(andn, src1 & ~src2);
LOGIC_IMPL(nand, ~(src1 & src2));
LOGIC_IMPL(or, src1 | src2);
LOGIC_IMPL(orn, src1 | ~src2);
LOGIC_IMPL(nor, ~(src1 | src2));
LOGIC_IMPL(xor, src1 ^ src2);
LOGIC_IMPL(xorn, src1 ^ ~src2);
LOGIC_IMPL(xnor, ~(src1 ^ src2));
LOGIC_IMPL(shl, src1 << src2);
LOGIC_IMPL(shr, src1 >> src2);
//--------------------------------------------------------------------------
IMPL_START_2(sal)
{
ALU_GET_SRCS();
long w1 = src1;
long w2 = src2;
w1 <<= w2;
v1 = (ulong)w1;
}
IMPL_OUT;
IMPL_START_2(sar)
{
ALU_GET_SRCS();
long w1 = src1;
long w2 = src2;
w1 >>= w2;
v1 = (ulong)w1;
}
IMPL_OUT;
//----------------------------------------------------------------------------//