WORD p_double_quote,'"',fasm ;; " (fool emacs)
;; ( -- char* n )
- ;; Scan to double quote in stream buffer, putting the string on PAD
+ ;; Scan to double quote in stream buffer, putting the string
+ ;; on PAD, plus an extra NUL, then copy that into a new temp
+ ;; object, but exclude the NUL from the returned count, n.
pushr rsi
push p_pad_DFA
push 0
jmp p_double_quote_loop
p_double_quote_endquote:
p_double_quote_endstream:
+ lea rdi,[p_pad_DFA]
+ add rdi,qword [rsp]
+ stosb
+ ;; copy PAD string into new temp object
+ inc qword [rsp]
+ DOFORTH p_str2temp
+ dec qword [rsp]
+ add qword [rsp+8],8 ; adjust pointer
popr rsi
next
--- /dev/null
+;;; Managing a memory area for temporary objects
+;;;
+;;; A temporary object space is allocated from the current usage
+;;; level, or cycling back to be from the lowest space address when
+;;; the requested size exceeds the space edge.
+;;;
+
+ WORD p_objectspace,'TEMPSPACE',dovariable
+ ;; Holds size and address of the object space.
+ dq 104857600 ; Total object space size (request size)
+ dq 0 ; Object space base address
+ dq 0 ; Currently used.
+
+ WORD p_temp,'TEMP',fasm
+ ;; ( size -- addr )
+ ;; Allocate an object of given size
+ pushr rsi
+ cmp qword [p_objectspace_DFA+8],0
+ jg p_objecthole_initialized
+ ;; initialize object space
+ push qword [p_objectspace_DFA]
+ DOFORTH p_malloc
+ pop qword [p_objectspace_DFA+8]
+p_objecthole_initialized:
+ mov rax,qword [rsp]
+ add rax,qword [p_objectspace_DFA+16]
+ cmp rax,qword [p_objectspace_DFA]
+ jl p_objecthole_from_tail
+ mov qword [p_objectspace_DFA+16],0
+ mov rax,qword [rsp]
+p_objecthole_from_tail:
+ mov rbx,qword [p_objectspace_DFA+16]
+ mov qword [p_objectspace_DFA+16],rax
+ add rbx,qword [p_objectspace_DFA+8]
+ mov qword [rsp],rbx
+ popr rsi
+ next
+
+ WORD p_str2temp,'STR>TEMP'
+ ;; ( char* n -- char* n )
+ ;; Capture a given [n:char*] string as a new temp object with
+ ;; leading size cell.
+ dq p_dup, p_gtR ; size
+ dq p_dup, p_temp
+ dq p_dup, p_gtR ; address
+ dq p_2dup, p_put
+ dq p_literal, 8, p_plus
+ dq p_swap, p_strncpy
+ dq p_Rgt, p_Rgt, p_swap
+ dq p_exit