added neg and bitnot to the stdlib and made a fib.sl example
This commit is contained in:
16
fib.sl
Normal file
16
fib.sl
Normal 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
|
||||
;
|
||||
@@ -413,3 +413,19 @@
|
||||
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
|
||||
}
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user