remove xor, rshr, rshl

This commit is contained in:
sfja 2026-11-15 19:16:04 +01:00
parent 1bafdb0595
commit eb4fe93a65
5 changed files with 17 additions and 24 deletions

View File

@ -7,18 +7,26 @@
not %0
@end
@macro xnor 2
xor %0, %1
not %0
@end
@macro nand 2
and %0, %1
not %0
@end
; %0 = %1 ^ %2
; %1 = !(%1 & %2)
@macro xor 3
mov %0, %1
or %0, %2
nand %1, %2
and %0, %1
@end
@macro xor 2
xor %0, fl, %1
@end
@macro clf 0
xor fl, fl
mov fl, 0
@end
@macro maske 0

View File

@ -1560,12 +1560,9 @@ static void a_parse_ins_args(Assembler *a, Op *op)
case Op_Cmp:
case Op_CMov:
case Op_Or:
case Op_Xor:
case Op_And:
case Op_Shr:
case Op_Shl:
case Op_RShr:
case Op_RShl:
case Op_Add:
case Op_Sub:
a_parse_op1_reg(a, op);

View File

@ -94,8 +94,6 @@ static uint16_t vm_arith(Opcode ty, uint16_t l, uint16_t r)
switch (ty) {
case Op_Or:
return l | r;
case Op_Xor:
return l ^ r;
case Op_And:
return l & r;
case Op_Not:
@ -104,10 +102,6 @@ static uint16_t vm_arith(Opcode ty, uint16_t l, uint16_t r)
return l >> r;
case Op_Shl:
return l << r;
case Op_RShr:
return r >> l;
case Op_RShl:
return r << l;
case Op_Add:
return l + r;
case Op_Sub:
@ -193,15 +187,12 @@ static void vm_run_op(VM *vm, VMState *s, const Op *op)
break;
}
case Op_Or:
case Op_Xor:
case Op_And:
case Op_Not:
case Op_Shr:
case Op_Shl:
case Op_RShr:
case Op_RShl:
case Op_Sub:
case Op_Add: {
case Op_Add:
case Op_Sub: {
uint16_t *l = &s->regs[op->op1_reg];
uint16_t r = op2_reg_or_imm(s, op);
*l = vm_arith(op->ty, *l, r);

View File

@ -14,13 +14,10 @@
X(Cmp, cmp) \
X(CMov, cmov) \
X(Or, or) \
X(Xor, xor) \
X(And, and) \
X(Not, not) \
X(Shr, shr) \
X(Shl, shl) \
X(RShr, rshr) \
X(RShl, rshl) \
X(Add, add) \
X(Sub, sub)

View File

@ -8,7 +8,7 @@ if exists("b:current_syntax")
endif
syn keyword vcKeyword nop hlt mov load store ldncr cmp cmov
syn keyword vcKeyword or xor and not shr shl rshr rshl add sub
syn keyword vcKeyword or and not shr shl add sub
syn keyword vcKeyword dw resw
syn keyword vcOperator r0 r1 r2 r3 sp bp fl ip