Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add multiplication operation

  • Loading branch information...
commit 3f1c21b0a6fc9e7f00ae7772c2bfeffab8a7fdee 1 parent eb5a59d
Bob Kuo authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 forth/words.pir
25 forth/words.pir
View
@@ -463,6 +463,31 @@ END_PIR
.return()
.end
+# multiplication
+.sub '*'
+ .param pmc code
+ .param pmc stream
+ .param pmc stack
+
+ .local string a, b
+ b = pop stack
+ a = pop stack
+ $P0 = get_root_global ['parrot';'PGE';'Util'], 'unique'
+ $S0 = $P0('$P')
+ $S1 = $P0('$P')
+ $S2 = $P0('$P')
+
+ code.'append_format'(<<'END_PIR', b, a, $S0, $S1, $S2)
+ %2 = %0
+ %3 = %1
+ %4 = new 'Float'
+ %4 = %3 * %2
+END_PIR
+ push stack, $S2
+
+ .return()
+.end
+
# Local Variables:
# mode: pir
# fill-column: 100
Please sign in to comment.
Something went wrong with that request. Please try again.