added neg and bitnot to the stdlib and made a fib.sl example

This commit is contained in:
IgorCielniak
2025-12-25 12:20:11 +01:00
parent 2b8cd25499
commit e2b1368899
2 changed files with 32 additions and 0 deletions

16
fib.sl Normal file
View File

@@ -0,0 +1,16 @@
import stdlib/stdlib.sl
import stdlib/io.sl
: main
1 1 2dup 2dup puti cr puti cr
+
dup puti cr
rot
22 dup >r for
2dup + dup puti cr
rot
next
"-------" puts
r> 3 + puti
" numbers printed from the fibonaci sequence" puts
;

View File

@@ -413,3 +413,19 @@
mov [r12], rax ; push value mov [r12], rax ; push value
} }
; ;
# : neg ( x -- -x )
:asm neg {
mov rax, [r12] ; get value
neg rax ; arithmetic negation
mov [r12], rax ; store result
}
;
# : bitnot ( 0|1 -- 1|0 )
:asm bitnot {
mov rax, [r12] ; get value
xor rax, 1 ; flip lowest bit
mov [r12], rax ; store result
}
;