изменен стиль кода, изменено расположение инструкций

This commit is contained in:
2024-02-13 12:33:31 +02:00
parent 061238db49
commit 48b53dc991
54 changed files with 524 additions and 484 deletions
+45
View File
@@ -0,0 +1,45 @@
use crate::stack::StackVec;
pub fn and(memory: &mut StackVec) {
let a: bool = memory.pop() == 1;
let b: bool = memory.pop() == 1;
let c: u16 = if a && b { 1 } else { 0 };
memory.push(c);
}
pub fn or(memory: &mut StackVec) {
let a: bool = memory.pop() == 1;
let b: bool = memory.pop() == 1;
let c: u16 = if a || b { 1 } else { 0 };
memory.push(c);
}
pub fn xor(memory: &mut StackVec) {
let a: bool = memory.pop() == 1;
let b: bool = memory.pop() == 1;
let c: u16 = if !a != !b { 1 } else { 0 };
memory.push(c);
}
pub fn nand(memory: &mut StackVec) {
let a: bool = memory.pop() == 1;
let b: bool = memory.pop() == 1;
let c: u16 = if !(a && b) { 1 } else { 0 };
memory.push(c);
}
pub fn not(memory: &mut StackVec) {
let a: bool = memory.pop() == 1;
let c: u16 = if !a { 1 } else { 0 };
memory.push(c);
}