From cabd8413c10848728efcc2b869f631294f755d4d Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Thu, 17 Jun 2021 16:57:56 +1000 Subject: [PATCH] identify TEMPUSED properly --- adoc/p_tempused.adoc | 15 +++++++++++++++ reference.adoc | 2 ++ temp.asm | 14 ++++++++++---- wordindex.adoc | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 adoc/p_tempused.adoc diff --git a/adoc/p_tempused.adoc b/adoc/p_tempused.adoc new file mode 100644 index 0000000..8c3b08f --- /dev/null +++ b/adoc/p_tempused.adoc @@ -0,0 +1,15 @@ +// temp.asm: WORD p_tempused,'TEMPUSED',dovariable + +anchor:p_tempused[] + +=== Word: TEMPUSED + +.... +Data stack: ( -- a ) +.... + +"TEMPUSED" is a variable word that keeps the lowest offset of the +<> space to use next as temporary space. This +is advance upon each allocation via <>, and recycled back +to <> when next allocation otherwise would exceed +the space size. diff --git a/reference.adoc b/reference.adoc index e48dbd7..b9f9b29 100644 --- a/reference.adoc +++ b/reference.adoc @@ -297,6 +297,8 @@ include::adoc/p_tempheld.adoc[] include::separator.adoc[] include::adoc/p_tempspace.adoc[] include::separator.adoc[] +include::adoc/p_tempused.adoc[] +include::separator.adoc[] include::adoc/p_terminate0.adoc[] include::separator.adoc[] include::adoc/p_tfa2cfa.adoc[] diff --git a/temp.asm b/temp.asm index 7ece590..932b1bb 100644 --- a/temp.asm +++ b/temp.asm @@ -11,6 +11,8 @@ ;; Holds size and address of the object space. dq 1073741824 ; [0] Total object space size (request size) dq 0 ; [8] Object space base address. + + WORD p_tempused,'TEMPUSED',dovariable dq 0 ; [16] Currently used. WORD p_tempheld,'TEMPHELD',dovariable @@ -29,19 +31,23 @@ DOFORTH p_malloc pop qword [p_objectspace_DFA+8] p_objecthole_initialized: + mov rax,qword [p_tempheld_DFA] + cmp rax,qword [p_tempused_DFA] + jl p_objecthole_recycle mov rax,qword [rsp] - add rax,qword [p_objectspace_DFA+16] + add rax,qword [p_tempused_DFA] cmp rax,qword [p_objectspace_DFA] jl p_objecthole_from_tail mov rax,qword [p_tempheld_DFA] ; cycling back to here - mov qword [p_objectspace_DFA+16],rax +p_objecthole_recycle: + mov qword [p_tempused_DFA],rax add rax,qword [rsp] p_objecthole_from_tail: ;; rax = new usage count - mov rbx,qword [p_objectspace_DFA+16] + mov rbx,qword [p_tempused_DFA] add rbx,qword [p_objectspace_DFA+8] mov qword [rsp],rbx - mov qword [p_objectspace_DFA+16],rax + mov qword [p_tempused_DFA],rax popr rsi next diff --git a/wordindex.adoc b/wordindex.adoc index c30b9bf..7cecd32 100644 --- a/wordindex.adoc +++ b/wordindex.adoc @@ -169,6 +169,7 @@ xref:p_dot_temp[.TEMP] {nbsp} xref:p_temp.adoc[TEMP] {nbsp} xref:p_tempheld.adoc[TEMPHELD] {nbsp} xref:p_tempspace[TEMPSPACE] {nbsp} +xref:p_tempused.adoc[TEMPUSED] {nbsp} xref:p_terminate0[TERMINATE0] {nbsp} xref:p_tfa2cfa[TFA>CFA] {nbsp} xref:p_tfa2dfa[TFA>DFA] {nbsp} -- 2.39.2