1 ;;; Words for stack manipulations
5 ;; Duplicate top ov stack value.
11 WORD p_2dup, '2DUP',fasm
12 ;; ( x1 x2 -- x1 x2 x1 x2 )
13 ;; Duplicate cell pair x1 x2.
18 WORD p_drop, 'DROP',fasm
20 ;; Remove x from the stack.
24 WORD p_2drop, '2DROP',fasm
26 ;; Drop cell pair x1 x2 from the stack.
30 WORD p_over, 'OVER',fasm
31 ;; ( x1 x2 -- x1 x2 x1 )
32 ;; Place a copy of x1 on top of the stack.
36 WORD p_2over, '2OVER',fasm
37 ;; ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 )
38 ;; Copy cell pair x1 x2 to the top of the stack.
43 WORD p_swap, 'SWAP',fasm
45 ;; Exchange the top two stack items.
52 WORD p_2swap, '2SWAP',fasm
53 ;; ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
54 ;; Exchange the top two cell pairs.
56 mov rbx,qword [rsp+16]
58 mov qword [rsp+16],rax
60 mov rbx,qword [rsp+24]
61 mov qword [rsp+8], rbx
62 mov qword [rsp+24],rax
65 WORD p_rot, 'ROT',fasm
66 ;; ( x1 x2 x3 -- x2 x3 x1 )
67 ;; Rotate the top three stack entries.
68 mov rax,qword [rsp+16]
70 mov qword [rsp+16],rbx
76 ;; ( xu xu-1 ... x0 u -- xu-1 ... x0 xu )
77 ;; Remove u. Rotate u+1 items on the top of the stack. An
78 ;; ambiguous condition exists if there are less than u+2 items
79 ;; on the stack before ROLL is executed.
80 WORD p_roll, 'ROLL',fasm
96 WORD p_nip, 'NIP',fasm
98 ;; Discard the second stack item.
103 WORD p_pick, 'PICK',fasm
104 ;; ( xu...x1 x0 u -- xu...x1 x0 xu )
105 ;; Remove u. Copy the xu to the top of the stack. An ambiguous
106 ;; condition exists if there are less than u+2 items on the
107 ;; stack before PICK is executed.
109 shl rax,3 ; 8 bytes per index
113 WORD w6.2.2300, 'TUCK',fasm
114 ;; ( x1 x2 -- x2 x1 x2 )
115 ;; insert the top stack value into below second stack value.
123 ;;; ========================================
124 ;;; Return stack operations
126 WORD p_ltR, '>R',fasm
127 ;; ( x -- ) ( R: -- x )
128 ;; Move x to the return stack.
133 WORD p_Rgt, 'R>',fasm
134 ;; ( -- x ) ( R: x -- )
135 ;; Move x from the return stack to the data stack.
140 WORD p_Rget, 'R@',fasm
141 ;; ( -- x ) ( R: x -- x )
142 ;; Copy x from the return stack to the data stack.