aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/elymasGlobal.ey18
-rw-r--r--doc/global.md13
2 files changed, 31 insertions, 0 deletions
diff --git a/compiler/elymasGlobal.ey b/compiler/elymasGlobal.ey
index cfa58cf..66ab27f 100644
--- a/compiler/elymasGlobal.ey
+++ b/compiler/elymasGlobal.ey
@@ -2056,6 +2056,24 @@
:retn
] /ey_ defv
+ # top stack element is an integer index into the stack,
+ # starting with 0 at the one below this index
+ # duplicates the indicated stack element to the top
+ [[
+ /rbx :popqReg
+ /rdx :popqReg
+ 63 /rdx :btrqImm8Reg
+ /unboxed :jcLbl8
+ 8 /rdx /rdx :movqMemDisp8Reg
+ @unboxed
+
+ 8 /rdx /rsp /rdx :movqMemIndexScaleReg
+ /rdx :pushqReg
+
+ /rbx :pushqReg
+ :retn
+ ]] /ey_' defv
+
# top stack element is a string defining a stack shuffle
# 0-9: push the thusly numbered element
# *: execute top element
diff --git a/doc/global.md b/doc/global.md
index e207973..99dc65c 100644
--- a/doc/global.md
+++ b/doc/global.md
@@ -311,6 +311,19 @@ Duplicates the top stack element.
0000000000000001
+`_'`
+---
+
+Takes from the top of the stack an integer. This is used as
+an index into the rest of the stack (starting from top).
+The specified stack element is duplicated to the top of the stack.
+
+ /a /b /c 1 _' dump dump dump dump
+ "b"
+ "c"
+ "b"
+ "a"
+
`-`
---