1 ;;; Managing a memory area for temporary objects
3 ;;; A temporary object space is allocated from the current usage
4 ;;; level, or cycling back to be from the lowest space address when
5 ;;; the requested size exceeds the space edge.
8 WORD p_objectspace,'TEMPSPACE',dovariable
9 ;; Holds size and address of the object space.
10 dq 104857600 ; [0] Total object space size (request size)
11 dq 0 ; [8] Object space base address
12 dq 0 ; [16] Currently used.
14 WORD p_temp,'TEMP',fasm
16 ;; Allocate an object of given size
18 cmp qword [p_objectspace_DFA+8],0
19 jg p_objecthole_initialized
20 ;; initialize object space
21 push qword [p_objectspace_DFA]
23 pop qword [p_objectspace_DFA+8]
24 p_objecthole_initialized:
26 add rax,qword [p_objectspace_DFA+16]
27 cmp rax,qword [p_objectspace_DFA]
28 jl p_objecthole_from_tail
29 mov qword [p_objectspace_DFA+16],0
31 p_objecthole_from_tail:
32 ;; rax = new usage count
33 mov rbx,qword [p_objectspace_DFA+16]
34 mov qword [p_objectspace_DFA+16],rax
35 add rbx,qword [p_objectspace_DFA+8]
40 WORD p_str2temp,'STR>TEMP',fasm
41 ;; ( char* n -- char* n )
42 ;; Capture a given [n:char*] string as a new temp object with
48 DOFORTH p_temp ; ( -- char* n addr )
58 push rbx ; ( -- addr n char* addr n )