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

76 lines
1.7 KiB
C
Raw Normal View History

2019-05-30 12:44:56 +02:00
// The OS/K Team licenses this file to you under the MIT license.
2019-05-29 16:57:22 +02:00
// See the LICENSE file in the project root for more information.
2019-06-05 12:53:09 +02:00
#include <in/instrs.h>
2019-05-29 16:57:22 +02:00
2019-07-04 18:41:05 +02:00
//----------------------------------------------------------------------------//
IMPL_START_2(not)
2019-06-12 15:30:35 +02:00
{
2019-07-04 18:41:05 +02:00
v1 = ~v2;
2019-06-12 15:30:35 +02:00
}
IMPL_OUT;
2019-05-30 20:27:11 +02:00
2019-05-29 16:57:22 +02:00
IMPL_START_2(test)
{
2019-07-11 18:34:21 +02:00
rfx &= ~(CF|OF);
2019-06-06 22:07:34 +02:00
SET_ZSF(v1 & v2);
2019-05-29 16:57:22 +02:00
}
IMPL_END;
2019-07-04 18:41:05 +02:00
//----------------------------------------------------------------------------//
2019-06-12 15:30:35 +02:00
2019-07-04 20:33:49 +02:00
#define LOGIC_IMPL(name, op) \
IMPL_START_2(name) \
{ \
ALU_GET_SRCS(); \
v1 = op; \
} \
2019-06-12 15:30:35 +02:00
IMPL_OUT;
2019-07-04 20:33:49 +02:00
LOGIC_IMPL(and, src1 & src2);
LOGIC_IMPL(andn, src1 & ~src2);
LOGIC_IMPL(nand, ~(src1 & src2));
2019-06-12 15:30:35 +02:00
2019-07-04 20:33:49 +02:00
LOGIC_IMPL(or, src1 | src2);
LOGIC_IMPL(orn, src1 | ~src2);
LOGIC_IMPL(nor, ~(src1 | src2));
2019-05-29 16:57:22 +02:00
2019-07-04 20:33:49 +02:00
LOGIC_IMPL(xor, src1 ^ src2);
LOGIC_IMPL(xorn, src1 ^ ~src2);
LOGIC_IMPL(xnor, ~(src1 ^ src2));
2019-06-12 15:30:35 +02:00
2019-07-04 20:33:49 +02:00
LOGIC_IMPL(shl, src1 << src2);
LOGIC_IMPL(shr, src1 >> src2);
2019-06-12 15:30:35 +02:00
//--------------------------------------------------------------------------
2019-05-29 16:57:22 +02:00
2019-06-23 20:56:04 +02:00
IMPL_START_2(sal)
{
2019-07-04 20:33:49 +02:00
ALU_GET_SRCS();
2019-06-23 20:56:04 +02:00
2019-07-04 20:33:49 +02:00
long w1 = src1;
long w2 = src2;
2019-06-23 20:56:04 +02:00
w1 <<= w2;
2019-07-04 20:33:49 +02:00
v1 = (ulong)w1;
2019-06-23 20:56:04 +02:00
}
2019-07-04 20:33:49 +02:00
IMPL_OUT;
2019-06-23 20:56:04 +02:00
IMPL_START_2(sar)
{
2019-07-04 20:33:49 +02:00
ALU_GET_SRCS();
2019-06-23 20:56:04 +02:00
2019-07-04 20:33:49 +02:00
long w1 = src1;
long w2 = src2;
2019-06-23 20:56:04 +02:00
w1 >>= w2;
2019-07-04 20:33:49 +02:00
v1 = (ulong)w1;
2019-06-23 20:56:04 +02:00
}
2019-07-04 20:33:49 +02:00
IMPL_OUT;
2019-06-23 20:56:04 +02:00
2019-07-04 18:41:05 +02:00
//----------------------------------------------------------------------------//
2019-06-23 20:56:04 +02:00