mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
79 lines
958 B
C
79 lines
958 B
C
// The OS/K Team licences this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
#include "instrs.h"
|
|
#include "arch_i.h"
|
|
|
|
//
|
|
// Comparison instructions
|
|
//
|
|
|
|
IMPL_START_2(test)
|
|
{
|
|
ulong v = v1 & v2;
|
|
|
|
if (v == 0) ctx->r[FLG].val |= ZF;
|
|
else ctx->r[FLG].val &= ~ZF;
|
|
}
|
|
IMPL_END;
|
|
|
|
IMPL_START_2(cmp)
|
|
{
|
|
if (v1 == v2) {
|
|
ctx->r[FLG].val |= ZF;
|
|
ctx->r[FLG].val &= ~CF;
|
|
}
|
|
|
|
else if (v1 < v2) {
|
|
ctx->r[FLG].val &= ~ZF;
|
|
ctx->r[FLG].val |= CF;
|
|
}
|
|
|
|
else {
|
|
ctx->r[FLG].val &= ~ZF;
|
|
ctx->r[FLG].val &= ~CF;
|
|
}
|
|
}
|
|
IMPL_END;
|
|
|
|
//
|
|
// Logical instructions
|
|
//
|
|
|
|
IMPL_START_2(and)
|
|
{
|
|
v1 &= v2;
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_2(or)
|
|
{
|
|
v1 |= v2;
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_2(xor)
|
|
{
|
|
v1 ^= v2;
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_2(shl)
|
|
{
|
|
v1 <<= v2;
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_2(shr)
|
|
{
|
|
v1 >>= v2;
|
|
}
|
|
IMPL_OUT;
|
|
|
|
IMPL_START_1(not)
|
|
{
|
|
v1 = ~v1;
|
|
}
|
|
IMPL_OUT;
|
|
|