Permalink
Browse files

begin, while, (asm loop)

  • Loading branch information...
1 parent 02445fe commit b8912b4f563fd5f594ac8755c5193eb4adddb33f Juan Felipe García Catalán committed May 7, 2012
Showing with 18 additions and 2 deletions.
  1. +18 −2 asm.ft
View
@@ -96,6 +96,13 @@ a special-op ias, b special-op rfi, c special-op iaq,
1f
nextword
then ;
+
+\ control structures
+: begin, ( -- addr ) here ;
+: while, ( addr -- ) l, pc, set, ;
+
+
+
\ we can now create codewords from gforth
: code create here here 1 - ! ;
@@ -123,13 +130,22 @@ decimal
\test asm words
code five ( n -- 5 )
-5 l, Zr [r] set,
+ 5 l, Zr [r] set,
next;
code d256 ( n -- 256 )
-256 l, Zr [r] set,
+ 256 l, Zr [r] set,
next;
+code pushfive ( -- 1 1 1 1 1 )
+ 0 l, Ar set,
+ begin,
+ 1 l, Zr sub,
+ 1 l, Zr [r] set,
+ 1 l, Ar add,
+ 5 l, Ar ifn, while,
+ next;
+
: gimmefive create code; 5 l, Zr [r] set, next;
\ don't save the new image, prepend to disasm.ft for now instead

0 comments on commit b8912b4

Please sign in to comment.