perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r35273 - trunk/languages/befunge

Subject: [svn:parrot] r35273 - trunk/languages/befunge
From:
Date: Fri, 9 Jan 2009 02:39:55 -0800 PST
Newsgroups: perl.cvs.parrot

Author: jquelin
Date: Fri Jan  9 02:39:53 2009
New Revision: 35273

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

Log:
instruction . implemented (integer output)


Modified: trunk/languages/befunge/befunge.pir
==============================================================================
--- trunk/languages/befunge/befunge.pir (original)
+++ trunk/languages/befunge/befunge.pir Fri Jan  9 02:39:53 2009
@@ -108,6 +108,7 @@
 
     # i/o operations
     if char == ',' goto IO_OUTPUT_CHAR
+    if char == '.' goto IO_OUTPUT_INT
     if char == 'g' goto IO_VALUE_GET
     if char == 'p' goto IO_VALUE_PUT
     
@@ -144,7 +145,7 @@
         # I/O operations.
         eq S0, "&", IO_INPUT_INT
         eq S0, "~", IO_INPUT_CHAR
-        eq S0, ".", IO_OUTPUT_INT
+        #eq S0, ".", IO_OUTPUT_INT
         #eq S0, ",", IO_OUTPUT_CHAR
         #eq S0, "g", IO_GET_VALUE
         #eq S0, "p", IO_PUT_VALUE
@@ -187,6 +188,9 @@
   IO_OUTPUT_CHAR:
     io__output_char()
     goto MOVE_PC
+  IO_OUTPUT_INT:
+    io__output_int()
+    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:39:53 2009
@@ -37,6 +37,21 @@
     print $S0
 .end
 
+#
+# io__output_int()
+#
+# output integer.
+# befunge stack:
+#   before:     ... i
+#   after:      ...
+# writeint(i)
+#
+.sub "io__output_int"
+    $I0 = stack__pop()
+    print $I0
+    print " "
+.end
+
 
 # ** playfield tinkering
 
@@ -136,20 +151,6 @@
     restore S2
     branch MOVE_PC
 
-# Output integer.
-# Befunge stack:
-#   before:     ... i
-#   after:      ...
-# writeint(i)
-IO_OUTPUT_INT:
-    set I10, P2
-    unless I10, IO_OUTPUT_INT_POP_1
-    pop I10, P2
-IO_OUTPUT_INT_POP_1:
-    print I10
-    print " "
-    branch MOVE_PC
-
 
 =cut
 

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r35273 - trunk/languages/befunge, jquelin <=