1 ;;; Words for stack manipulations
3 WORD p_depth,'DEPTH',fasm
5 ;; Push stack depth (before push)
12 WORD p_dup, 'DUP',fasm
14 ;; Duplicate top ov stack value.
15 ;; push qword [rsp] ??
20 WORD p_2dup, '2DUP',fasm
21 ;; ( x1 x2 -- x1 x2 x1 x2 )
22 ;; Duplicate cell pair x1 x2.
27 WORD p_drop, 'DROP',fasm
29 ;; Remove x from the stack.
33 WORD p_2drop, '2DROP',fasm
35 ;; Drop cell pair x1 x2 from the stack.
39 WORD p_over, 'OVER',fasm
40 ;; ( x1 x2 -- x1 x2 x1 )
41 ;; Place a copy of x1 on top of the stack.
45 WORD p_2over, '2OVER',fasm
46 ;; ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 )
47 ;; Copy cell pair x1 x2 to the top of the stack.
52 WORD p_swap, 'SWAP',fasm
54 ;; Exchange the top two stack items.
61 WORD p_2swap, '2SWAP',fasm
62 ;; ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
63 ;; Exchange the top two cell pairs.
65 mov rbx,qword [rsp+16]
67 mov qword [rsp+16],rax
69 mov rbx,qword [rsp+24]
70 mov qword [rsp+8], rbx
71 mov qword [rsp+24],rax
74 WORD p_rot, 'ROT',fasm
75 ;; ( x1 x2 x3 -- x2 x3 x1 )
76 ;; Rotate the top three stack entries.
77 mov rax,qword [rsp+16]
79 mov qword [rsp+16],rbx
85 ;; ( xu xu-1 ... x0 u -- xu-1 ... x0 xu )
86 ;; Remove u. Rotate u+1 items on the top of the stack. An
87 ;; ambiguous condition exists if there are less than u+2 items
88 ;; on the stack before ROLL is executed.
89 WORD p_roll, 'ROLL',fasm
105 WORD p_nip, 'NIP',fasm
107 ;; Discard the second stack item.
112 WORD p_pick, 'PICK',fasm
113 ;; ( xu...x1 x0 u -- xu...x1 x0 xu )
114 ;; Remove u. Copy the xu to the top of the stack. An ambiguous
115 ;; condition exists if there are less than u+2 items on the
116 ;; stack before PICK is executed.
118 shl rax,3 ; 8 bytes per index
122 WORD p_tuck, 'TUCK',fasm
123 ;; ( x1 x2 -- x2 x1 x2 )
124 ;; copy the top stack value into below second stack value.
132 ;;; ========================================
133 ;;; Return stack operations
135 WORD p_gtR, '>R',fasm
136 ;; ( x -- ) ( R: -- x )
137 ;; Move x to the return stack.
142 WORD p_Rgt, 'R>',fasm
143 ;; ( -- x ) ( R: x -- )
144 ;; Move x from the return stack to the data stack.
149 WORD p_Rget, 'R@',fasm
150 ;; ( -- x ) ( R: x -- x )
151 ;; Copy x from the return stack to the data stack.