Author: jquelin
Date: Fri Jan 9 02:35:49 2009
New Revision: 35271
Modified:
trunk/languages/befunge/befunge.pir
trunk/languages/befunge/stack.pir
Log:
instruction \ implemented (swap stack)
Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir (original)
+++ trunk/languages/befunge/befunge.pir Fri Jan 9 02:35:49 2009
@@ -104,6 +104,7 @@
# stack operations
if char == ':' goto STACK_DUP
if char == '$' goto STACK_POP
+ if char == '\' goto STACK_SWAP
# i/o operations
if char == ',' goto IO_OUTPUT_CHAR
@@ -138,7 +139,7 @@
# Stack operations.
#eq S0, ":", STACK_DUP
#eq S0, "$", STACK_POP
- eq S0, "\\", STACK_SWAP
+ #eq S0, "\\", STACK_SWAP
# I/O operations.
eq S0, "&", IO_INPUT_INT
@@ -223,6 +224,9 @@
STACK_POP:
$I0 = stack__pop()
goto MOVE_PC
+ STACK_SWAP:
+ $I0 = stack__swap()
+ goto MOVE_PC
# instruction executed, now move the pc
Modified: trunk/languages/befunge/stack.pir
==============================================================================
--- trunk/languages/befunge/stack.pir (original)
+++ trunk/languages/befunge/stack.pir Fri Jan 9 02:35:49 2009
@@ -58,6 +58,20 @@
.end
+#
+# stack__swap()
+#
+# swap.
+# befunge stack:
+# before: ... a b
+# after: ... b a
+.sub "stack__swap"
+ $I0 = stack__pop()
+ $I1 = stack__pop()
+ stack__push($I0)
+ stack__push($I1)
+.end
+
=pod
STACK_POP:
@@ -67,10 +81,6 @@
STACK_POP_POP_1:
branch MOVE_PC
-# Swap.
-# Befunge stack:
-# before: ... a b
-# after: ... b a
STACK_SWAP:
set I10, P2
unless I10, STACK_SWAP_POP_1