1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; UrForth level
1: self
-hosting
32-bit Forth compiler
3 ;; Copyright
(C
) 2020 Ketmar Dark
// Invisible Vector
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;; brk
-buffer chain
; we have
to restore all those buffers on loading
13 $variable
"(brk-buf-chain)" 0
16 : (add
-brk
-buffer
) ( size valpfa
-- )
19 (brk
-buf
-chain
) @ over
!
20 dup
(brk
-buf
-chain
) ! cell
+
25 endcr
." (save-add-brk-buffer): valpfa=0x" (brk
-buf
-chain
) @ cell
+ @
.hex8
26 ." ; size=" (brk
-buf
-chain
) @
2 +cells @
.hex8
27 ." ; name=" (brk
-buf
-chain
) @ cell
+ @ pfa
->cfa cfa
->nfa id
. cr
32 : (restore
-brk
-buffers
) ( size valpfa
-- )
38 cell
+ dup @ swap
;; valpfa
44 endcr
." (save-restore-brk-buffers): valpfa=0x" r@ cell
+ @
.hex8
45 ." ; size=" r@
2 +cells @
.hex8
46 ." ; name=" r@ cell
+ @ pfa
->cfa cfa
->nfa id
. cr
52 ..: (startup
-init
) (restore
-brk
-buffers
) ;..
55 ;; this allocates memory with BRK
56 : BRK
-BUFFER
: ( size
-- )
57 dup
>r
;; we should notify saver about new buffer here
, hence the save
59 r
> latest
-cfa cfa
->pfa
(add
-brk
-buffer
)