From d2f33fe305f6a2a4ad2a18f1eafc4e1e4741bd8c Mon Sep 17 00:00:00 2001 From: Drahflow Date: Mon, 21 Aug 2017 07:52:18 +0200 Subject: Added _' for indexed access to stack --- compiler/elymasGlobal.ey | 18 ++++++++++++++++++ doc/global.md | 13 +++++++++++++ 2 files changed, 31 insertions(+) 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" + `-` --- -- cgit v1.2.3