slc/examples/numbers.slc

43 lines
1002 B
Plaintext
Raw Normal View History

// There are no "types", but we have typed operations
// Immediates are 31 bit, unsigned when we see a number
// This way we can bytecode topmost bit 1n...n a number!
40
2
+
. // 42
// If you want to do negative numbers use "neg"
// This is different from ~ which is bitwise negation as this is two's complement
// To create HUGE immediates - like over 31 bit, but smaller than 32.. just use long pls
// I mean.. values can fit to 32 bit properly on calculation
42
neg
i. // -42; there is also li.
// You can also do this:
hex(ffffffff)
1
+
. // 0
// Rem.: Yes, the hex word uses two pushes and first creates the 1.....10 part, then 0....01 part and use '|' on them
// but if you are not using the topmost bits, this can be optimized out in the implementation of course too.
l(3)
l(2)
l+
l. // 5 - 64bit calculation
f(3)
f(2.5)
f+
f. // 5.5
d(3)
d(2.5)
d+
d. // 5.5
// The +- sign does not count, */ are by default unsigned - use i* and i/ for signd imul, idiv. Also there is li* and li/