code cleanup + added 'bitnot`, `bitor` and `bitxor`
drkameleon yaniszaf@gmail.com
Thu, 21 Jan 2021 13:49:52 +0100
1 files changed,
23 insertions(+),
3 deletions(-)
jump to
M
minpkg/lib/min_binary.nim
→
minpkg/lib/min_binary.nim
@@ -7,12 +7,32 @@
proc binary_module*(i: In)= let def = i.define() - + def.symbol("bitand") do (i: In): let vals = i.expect("int","int") let b = vals[0] let a = vals[1] - i.push newVal(a.intVal mod b.intVal) + i.push newVal(a.intVal and b.intVal) + + def.symbol("bitnot") do (i: In): + let vals = i.expect("int") + let a = vals[0] + + i.push newVal(not a.intVal) - def.finalize("binary") + def.symbol("bitor") do (i: In): + let vals = i.expect("int","int") + let b = vals[0] + let a = vals[1] + + i.push newVal(a.intVal or b.intVal) + + def.symbol("bitxor") do (i: In): + let vals = i.expect("int","int") + let b = vals[0] + let a = vals[1] + + i.push newVal(a.intVal xor b.intVal) + + def.finalize("binary")