Author: jquelin
Date: Wed Jan 7 10:26:17 2009
New Revision: 35161
Modified:
trunk/languages/befunge/befunge.pir
trunk/languages/befunge/io.pir
Log:
string mode implemented (push char)
Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir (original)
+++ trunk/languages/befunge/befunge.pir Wed Jan 7 10:26:17 2009
@@ -54,7 +54,7 @@
# S2 = user input
# S0 = current instruction
- .local int x, y, val
+ .local int x, y, flag, val
.local string char
TICK:
status = get_global "status"
@@ -62,6 +62,7 @@
y = status["y"]
val = playfield[y;x]
char = chr val
+ flag = status["flag"]
status["char"] = char
status["val"] = val
set_global "status", status
@@ -71,6 +72,7 @@
TICK_NODEBUG:
if char == '"' goto FLOW_TOGGLE_STRING_MODE
+ if flag == 1 goto IO_PUSH_CHAR
# sole number
@@ -150,6 +152,11 @@
flow__toggle_string_mode()
goto MOVE_PC
+ # io instructions
+ IO_PUSH_CHAR:
+ io__push_char()
+ goto MOVE_PC
+
=pod
MAIN_TRAMPOLINE:
Modified: trunk/languages/befunge/io.pir
==============================================================================
--- trunk/languages/befunge/io.pir (original)
+++ trunk/languages/befunge/io.pir Wed Jan 7 10:26:17 2009
@@ -1,16 +1,26 @@
# $Id$
-=pod
+# ** string mode
-# String mode.
-# Befunge stack:
+#
+# string mode.
+# befunge stack:
# before: ...
# after: ... c
-# i = ord(current char)
+# c = ord(current char)
+.sub io__push_char
+ $P0 = get_global "status"
+ $P1 = get_global "stack"
+
+ $I0 = $P0["val"]
+ push $P1, $I0
+
+ set_global "stack", $P1
+.end
+
+=pod
+
IO_PUSH_CHAR:
- ord I10, S0
- push P2, I10
- branch MOVE_PC
# Input integer.
# Befunge stack: