1 ;;; Managing a memory area for temporary "objects".
3 ;;; Object space is allocated cyclically, starting subsequent to prior
4 ;;; allocation and cycling back when requested object size exceeds
5 ;;; the space edge. The "inital" part, which starts as empty, is
6 ;;; considered "held" space that is not reused when cycling back, and
7 ;;; apart from allowing for this, the space management is left open.
10 WORD p_objectspace,'TEMPSPACE',dovariable
11 ;; Holds size and address of the object space.
12 dq 1073741824 ; [0] Total object space size (request size)
13 dq 0 ; [8] Object space base address.
14 dq 0 ; [16] Currently used.
16 WORD p_tempheld,'TEMPHELD',dovariable
18 ;; Marks the barrier for "held space"
19 dq 0 ; [24] Currently held.
21 WORD p_temp,'TEMP',fasm
23 ;; Allocate an object of given size
25 cmp qword [p_objectspace_DFA+8],0
26 jg p_objecthole_initialized
27 ;; initialize object space
28 push qword [p_objectspace_DFA]
30 pop qword [p_objectspace_DFA+8]
31 p_objecthole_initialized:
33 add rax,qword [p_objectspace_DFA+16]
34 cmp rax,qword [p_objectspace_DFA]
35 jl p_objecthole_from_tail
36 mov rax,qword [p_tempheld_DFA] ; cycling back to here
37 mov qword [p_objectspace_DFA+16],rax
39 p_objecthole_from_tail:
40 ;; rax = new usage count
41 mov rbx,qword [p_objectspace_DFA+16]
42 add rbx,qword [p_objectspace_DFA+8]
44 mov qword [p_objectspace_DFA+16],rax
48 WORD p_str2temp,'STR>TEMP',fasm
49 ;; ( char* n -- char* n )
50 ;; Capture a given [n:char*] string as a new temp object with
56 DOFORTH p_temp ; ( -- char* n addr )
66 push rbx ; ( -- addr n char* addr n )