Author: jquelin
Date: Fri Jan  9 02:16:18 2009
New Revision: 35265

Modified:
   trunk/languages/befunge/befunge.pir
   trunk/languages/befunge/io.pir

Log:
instruction , implemented (output char)


Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir (original)
+++ trunk/languages/befunge/befunge.pir Fri Jan  9 02:16:18 2009
@@ -101,6 +101,7 @@
     if char == ':' goto STACK_DUP
 
     # i/o operations
+    if char == ',' goto IO_OUTPUT_CHAR
     if char == 'g' goto IO_VALUE_GET
     if char == 'p' goto IO_VALUE_PUT
     
@@ -138,7 +139,7 @@
         eq S0, "&", IO_INPUT_INT
         eq S0, "~", IO_INPUT_CHAR
         eq S0, ".", IO_OUTPUT_INT
-        eq S0, ",", IO_OUTPUT_CHAR
+        #eq S0, ",", IO_OUTPUT_CHAR
         #eq S0, "g", IO_GET_VALUE
         #eq S0, "p", IO_PUT_VALUE
 
@@ -174,6 +175,9 @@
     goto MOVE_PC
 
     # io instructions
+  IO_OUTPUT_CHAR:
+    io__output_char()
+    goto MOVE_PC
   IO_PUSH_CHAR:
     io__push_char()
     goto MOVE_PC

Modified: trunk/languages/befunge/io.pir
==============================================================================
--- trunk/languages/befunge/io.pir      (original)
+++ trunk/languages/befunge/io.pir      Fri Jan  9 02:16:18 2009
@@ -22,6 +22,21 @@
 
 # ** output
 
+#
+# io__output_char()
+#
+# output character.
+# befunge stack:
+#   before:     ... i
+#   after:      ...
+# writechar( chr(i) )
+#
+.sub "io__output_char"
+    $I0 = stack__pop()
+    $S0 = chr $I0
+    print $S0
+.end
+
 
 # ** playfield tinkering
 
@@ -135,20 +150,6 @@
     print " "
     branch MOVE_PC
 
-# Output character.
-# Befunge stack:
-#   before:     ... i
-#   after:      ...
-# writechar( chr(i) )
-IO_OUTPUT_CHAR:
-    set I10, P2
-    unless I10, IO_OUTPUT_CHAR_POP_1
-    pop I10, P2
-IO_OUTPUT_CHAR_POP_1:
-    chr S10, I10
-    print S10
-    branch MOVE_PC
-
 
 =cut
 

Reply via email to