--- /dev/null
+// compile.asm: WORD p_Dcomma,'D,',fasm
+
+anchor:p_Dcomma[]
+
+=== Word: D,
+
+
+....
+Data stack: ( v -- )
+....
+
+"D," (D-comma) is a function word that puts a "double word"
+(double-byte) on the <<p_here,HERE>> heap. The four least significant
+bytes of the value are put at the current free head address, which
+also is incremented accordingly.
+
+====
+.Definition concept for D,
+****
+: D, HERE @ 4 ALLOT D! ;
+****
+====
+
--- /dev/null
+// memory.asm: WORD p_Dget, 'D@',fasm
+
+anchor:p_Dget[]
+
+=== Word: D@
+
+....
+Data stack: ( a -- v )
+....
+
+"D@" is a function word that pushes the "double word" (4-byte) value v
+from the address a.
+
--- /dev/null
+// memory.asm: WORD p_Dput, 'D!',fasm
+
+anchor:p_Dput[]
+
+=== Word: D!
+
+....
+Data stack: ( v a -- )
+....
+
+"D!" is a function word that stores the "doublw word" (4-byte) value v
+(the four least significant bytes of the cell) at the address a.
+
--- /dev/null
+// compile.asm: WORD p_Wcomma,'W,',fasm
+
+anchor:p_Wcomma[]
+
+=== Word: W,
+
+
+....
+Data stack: ( v -- )
+....
+
+"W," (W-comma) is a function word that puts a "word" (double-byte) on
+the <<p_here,HERE>> heap. The two least significant bytes of the value
+are put at the current free head address, which also is incremented
+accordingly.
+
+====
+.Definition concept for W,
+****
+: W, HERE @ 2 ALLOT W! ;
+****
+====
+
--- /dev/null
+// memory.asm: WORD p_Wget, 'W@',fasm
+
+anchor:p_Wget[]
+
+=== Word: W@
+
+....
+Data stack: ( a -- v )
+....
+
+"W@" is a function word that pushes the "word" (double-byte) value v
+from the address a.
+
--- /dev/null
+// memory.asm: WORD p_Wput, 'W!',fasm
+
+anchor:p_Wput[]
+
+=== Word: W!
+
+....
+Data stack: ( v a -- )
+....
+
+"W!" is a function word that stores the "word" (2-byte) value v (the
+two least significant bytes of the cell) at the address a.
+
;; Compile down " LIT value "
dq p_literal, p_literal, p_comma,p_quote, p_comma, p_return
- WORD p_comma,','
- ;; ( v -- )
- ;; Put cell value onto the heap and advance "HERE"
- dq p_here, p_literal, 8, p_get_n_increment, p_put, p_return
-
WORD p_Ccomma,'C,'
;; ( c -- )
;; Put byte value onto the heap and advance "HERE"
- dq p_here, p_Cput, p_literal, 1, p_here, p_put_plus, p_return
+ mov rax,[p_here_DFA]
+ pop rbx
+ mov byte [rax],bl
+ inc qword [p_here_DFA]
+ next
+
+ WORD p_Wcomma,'W,'
+ ;; ( c -- )
+ ;; Put byte value onto the heap and advance "HERE"
+ mov rax,[p_here_DFA]
+ pop rbx
+ mov word [rax],bx
+ add qword [p_here_DFA],2
+ next
+
+ WORD p_Dcomma,'D,'
+ ;; ( d -- )
+ ;; Put byte value onto the heap and advance "HERE"
+ mov rax,[p_here_DFA]
+ pop rbx
+ mov dword [rax],ebx
+ add qword [p_here_DFA],4
+ next
+
+ WORD p_comma,','
+ ;; ( v -- )
+ ;; Put byte value onto the heap and advance "HERE"
+ mov rax,[p_here_DFA]
+ pop rbx
+ mov qword [rax],rbx
+ add qword [p_here_DFA],8
+ next
WORD p_does,"DOES>",fasm,IMMEDIATE
;; ( -- )
mov byte [rax], bl
next
+ WORD p_Wget, 'W@',fasm
+ ;; ( addr -- v )
+ ;; Load the (unsigned) double-byte v from address addr.
+ pop rax
+ mov bx,[rax]
+ push 0
+ mov word [rsp],bx
+ next
+
+ WORD p_Wput, 'W!',fasm
+ ;; ( v addr -- )
+ ;; Store byte value v at address addr.
+ pop rax
+ pop rbx
+ mov word [rax], bx
+ next
+
+ WORD p_Dget, 'D@',fasm
+ ;; ( addr -- v )
+ ;; Load the (unsigned) double-byte v from address addr.
+ pop rax
+ mov ebx,[rax]
+ push 0
+ mov dword [rsp],ebx
+ next
+
+ WORD p_Dput, 'D!',fasm
+ ;; ( v addr -- )
+ ;; Store byte value v at address addr.
+ pop rax
+ pop rbx
+ mov dword [rax], ebx
+ next
+
WORD p_2get, '2@',fasm
;; ( addr -- v2 v1 )
;; Load the cell pair {v1,v2} from address addr.
include::separator.adoc[]
include::adoc/p_Ccomma.adoc[]
include::separator.adoc[]
+include::adoc/p_Wcomma.adoc[]
+include::separator.adoc[]
+include::adoc/p_Dcomma.adoc[]
+include::separator.adoc[]
include::adoc/p_cfa2tfa.adoc[]
include::separator.adoc[]
include::adoc/p_Cget.adoc[]
include::separator.adoc[]
+include::adoc/p_Wget.adoc[]
+include::separator.adoc[]
+include::adoc/p_Rget.adoc[]
+include::separator.adoc[]
include::adoc/p_Cput.adoc[]
include::separator.adoc[]
+include::adoc/p_Wput.adoc[]
+include::separator.adoc[]
+include::adoc/p_Dput.adoc[]
+include::separator.adoc[]
include::adoc/p_Rget.adoc[]
include::separator.adoc[]
include::adoc/p_Rgt.adoc[]
popr rsi
next
+;;; ========================================
+;;; Copy line to PAD
+;;; READ-STREAM-LINE ( stream -- n )
+
+ WORD p_read_stream_line,'READ-STREAM-LINE'
+ ;; ( stream -- n )
+ ;; Read stream until next newline
+ dq p_gtR, p_pad
+p_read_stream_line_loop:
+ dq p_Rget, p_read_stream_char
+ dq p_dup, p_0less
+ BRANCH 1,p_read_stream_line_done
+ dq p_dup, p_nl, p_equal
+ BRANCH 1,p_read_stream_line_done
+ dq p_over, p_Cput, p_literal,1, p_plus
+ BRANCH ,p_read_stream_line_loop
+p_read_stream_line_done:
+ dq p_drop, p_literal,0, p_over, p_Cput
+ dq p_pad, p_minus, p_return
+
+
;;; ========================================
;;; Stream reading
;;; READ-STREAM-CHAR ( stream -- ch )
xref:p_put[!] {nbsp}
xref:p_Cget[C@] {nbsp}
xref:p_Cput[C!] {nbsp}
+xref:p_Wget[W@] {nbsp}
+xref:p_Wput[W!] {nbsp}
+xref:p_Dget[D@] {nbsp}
+xref:p_Dput[D!] {nbsp}
xref:p_2get[2@] {nbsp}
xref:p_2put[2!] {nbsp}
xref:p_put_plus[!{plus}] {nbsp}
xref:p_get_n_increment[@n{plus}{plus}] {nbsp}
xref:p_get_n_decrement[@n--] {nbsp}
xref:p_Ccomma[C,] {nbsp}
+xref:p_Wcomma[W,] {nbsp}
+xref:p_Dcomma[D,] {nbsp}
xref:p_literal_string_compile[S"] {nbsp}
xref:p_gtR[>R] {nbsp}
xref:p_Rget[R@] {nbsp}