2026-01-08 13:15:27 +01:00
|
|
|
import ../stdlib/stdlib.sl
|
|
|
|
|
import ../stdlib/io.sl
|
|
|
|
|
import ../stdlib/mem.sl
|
2025-12-28 11:46:01 +01:00
|
|
|
|
2026-01-08 15:28:10 +01:00
|
|
|
word test-mem-alloc
|
2026-02-02 15:51:58 +01:00
|
|
|
4096 alloc dup 1337 ! # allocate 4096 bytes, store 1337 at start
|
2025-12-28 11:46:01 +01:00
|
|
|
dup @ puti cr # print value at start
|
|
|
|
|
4096 free # free the memory
|
2026-01-08 15:28:10 +01:00
|
|
|
end
|
2025-12-28 11:46:01 +01:00
|
|
|
|
2026-01-21 14:26:30 +01:00
|
|
|
struct Point
|
2025-12-28 11:46:01 +01:00
|
|
|
field x 8
|
|
|
|
|
field y 8
|
2026-01-21 14:26:30 +01:00
|
|
|
end
|
2025-12-28 11:46:01 +01:00
|
|
|
|
2026-01-08 15:28:10 +01:00
|
|
|
word main
|
2025-12-28 11:46:01 +01:00
|
|
|
32 alloc # allocate 32 bytes (enough for a Point struct)
|
2026-01-12 08:42:54 +01:00
|
|
|
dup
|
2026-02-02 15:51:58 +01:00
|
|
|
dup 111 Point.x! # store 111 at offset 0 (Point.x)
|
|
|
|
|
dup 222 Point.y! # store 222 at offset 8 (Point.y)
|
|
|
|
|
dup Point.x@ puti cr # print x
|
|
|
|
|
dup Point.y@ puti cr # print y
|
2025-12-28 11:46:01 +01:00
|
|
|
32 free # free the memory
|
2026-01-12 08:42:54 +01:00
|
|
|
end
|