dq 0 ; [24] Currently held.
WORD p_temp,'TEMP',fasm
- ;; ( size -- addr )
- ;; Allocate an object of given size
+ ;; ( n -- a ; allocate a temp region of given size )
pushr rsi
cmp qword [p_objectspace_DFA+8],0
- jg p_objecthole_initialized
- ;; initialize object space
+ jg p_temp_initialized
push qword [p_objectspace_DFA]
DOFORTH p_malloc
pop qword [p_objectspace_DFA+8]
-p_objecthole_initialized:
+p_temp_initialized:
+ ;;-- temp space is initialised (allocated)
+ ;;---- first test for a possible "forced cycling", in case
+ ;;---- TEMPHELD@ has been moved above TEMPUSED@.
mov rax,qword [p_tempheld_DFA]
cmp rax,qword [p_tempused_DFA]
- jl p_objecthole_recycle
+ jg p_temp_cycle
+p_temp_checklimit:
+ ;;-- consider using object at TEMPUSED@
mov rax,qword [rsp]
add rax,qword [p_tempused_DFA]
cmp rax,qword [p_objectspace_DFA]
- jl p_objecthole_from_tail
+ jl p_temp_from_tail ; jmp = tail is large enough
+p_temp_cycle:
+ ;;-- recycle temp space from TEMPHELD@
mov rax,qword [p_tempheld_DFA] ; cycling back to here
-p_objecthole_recycle:
mov qword [p_tempused_DFA],rax
add rax,qword [rsp]
-p_objecthole_from_tail:
+ ;;-- note that possible tail overflow is ignored here!!
+p_temp_from_tail:
;; rax = new usage count
mov rbx,qword [p_tempused_DFA]
- add rbx,qword [p_objectspace_DFA+8]
+ add rbx,qword [p_objectspace_DFA+8] ; form actual pointer
mov qword [rsp],rbx
mov qword [p_tempused_DFA],rax
popr rsi