aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/reverse.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/common/lib/reverse.frt')
-rw-r--r--amforth-6.5/common/lib/reverse.frt17
1 files changed, 17 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/reverse.frt b/amforth-6.5/common/lib/reverse.frt
new file mode 100644
index 0000000..9d468f4
--- /dev/null
+++ b/amforth-6.5/common/lib/reverse.frt
@@ -0,0 +1,17 @@
+\ LIFO made FIFO
+\ ( X1 .. Xn n -- Xn .. X1 n )
+: reverse
+ >r
+ sp@ sp@ r@ cells + \ ( bot-addr top-addr )
+ begin
+ over over < \ bot top cross each other?
+ while \ no
+ dup @ >r \ save top-cell content
+ over @ over ! \ replace top-cell
+ over r> swap ! \ replace bot-cell
+ cell- swap cell+ swap
+ repeat
+ 2drop
+ r>
+;
+