hex.pop¶
Effectively: sp -= M
hex[:n] = stack[sp+1:][:M]
Pops multiple stack cell into the given hex[:n]. Decrements sp by M.
M is (n+1)/2, which is because the function pops all the parameters as bytes.
Note: The pops assume that they were pushed as bytes to the stack (2 hexs in one stack-cell).
So this macro pops bytes.
Note: The push/pop usage must be coordinated, and every push X must be untangled by a pop X (or a sp_sub (X+1)/2)
For example: “push 3; push 3” can’t be read with a “pop 6”. That’s because each “push 3” takes 2 stack cells,
while the “pop 6” only pops out 3 stack cells (so there is another cell that needs to be popped.
hex[:n] is only an output parameter.
Signature¶
def pop n, hex { ... }
Defined in hex/pointers/stack.fj — lines 124–127 (view on GitHub).
Complexity¶
Time:
n(w(0.38@+ 3) + 9@+18)Space:
n(w(0.56@+16) + 7@+70)
See the complexity glossary for what @, w, dw, dbit, n mean.
Source¶
Click to view the macro body
def pop n, hex {
rep(n%2, i) .pop_hex hex+(n-1)*dw
rep(n/2, i) .pop_byte hex+(n-n%2-2*(i+1))*dw
}
← Previous: hex.pop_byte