identify TEMPUSED properly
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 17 Jun 2021 06:57:56 +0000 (16:57 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Thu, 17 Jun 2021 06:57:56 +0000 (16:57 +1000)
adoc/p_tempused.adoc [new file with mode: 0644]
reference.adoc
temp.asm
wordindex.adoc

diff --git a/adoc/p_tempused.adoc b/adoc/p_tempused.adoc
new file mode 100644 (file)
index 0000000..8c3b08f
--- /dev/null
@@ -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
+<<p__tempspace,TEMPSPACE>> space to use next as temporary space. This
+is advance upon each allocation via <<p_temp,TEMP>>, and recycled back
+to <<p_tempheld,TEMPHELD>> when next allocation otherwise would exceed
+the space size.
index e48dbd742b288fd8e2714e40fbd4a2dbffe8d6c1..b9f9b29c321d25b75a07719e675e1dd10baa752f 100644 (file)
@@ -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[]
index 7ece59078005ddfdcc740aba3d82c3afcbfa06f1..932b1bb3e9e26bf4bf9d3fce01cbc231bbc171af 100644 (file)
--- 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
        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
 
index c30b9bf6566a9d873506545f3142b0eb3d5a5372..7cecd32542f837412ab2d7687c6969a76542931d 100644 (file)
@@ -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}