Implemented basic support for function pointers

This commit is contained in:
2025-01-30 16:33:20 +01:00
parent a2d80b0c21
commit 162824ec1c
8 changed files with 166 additions and 15 deletions

23
examples/thread/thread.q Normal file
View File

@ -0,0 +1,23 @@
import mem
import sys
main() {
start()
start()
start()
thread()
}
start() {
size := 4096
stack := mem.alloc(size)
pointer := stack + size - 8
store(pointer, 8, thread)
sys.clone(0x100 | 0x200 | 0x400 | 0x800 | 0x8000 | 0x10000 | 0x80000000, pointer)
}
thread() {
sys.write(1, "[ ] start\n", 10)
sys.write(1, "[x] end\n", 8)
sys.exit(0)
}