Skip to content

Commit

Permalink
Add fib.ir example and update argument documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
simon816 committed Jun 10, 2019
1 parent 09c77f6 commit 3bedffc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions examples/fib.ir
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
preamble {
$all_players = selector a
}

function main {
preamble {
$x = define i32
$y = define i32
$old_x = define i32
$counter = define i32
extern
}

entry:
$x = 0
$y = 1
$counter = 1
branch :loop

loop:
$msg = text
text_append $msg, "fib("
text_append $msg, $counter
text_append $msg, ") = "
text_append $msg, $x
text_send $msg, $all_players
set_command_block :post_tick

post_tick:
clear_command_block
$counter += 1
$old_x = $x
$x = $y
$y += $old_x
rangebr $x, 0, NULL, :loop, :end

end:
ret
}
4 changes: 2 additions & 2 deletions ir_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def main(args):

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('file', help="ASM File", type=argparse.FileType('r'))
parser.add_argument('file', help="Command IR File", type=argparse.FileType('r'))
parser.add_argument('--world-dir', help="World Directory")
parser.add_argument('--as-zip', action='store_true', help="Write datapack as zip file")
parser.add_argument('--namespace', help="Function namespace", default='ir_generated')
parser.add_argument('--rem-existing', help="Remove existing functions in namespace",
action='store_true')
parser.add_argument('--debug', action='store_true', help="Enable debug output")
parser.add_argument('--dump-ir', action='store_true', help="Dump CMD IR output")
parser.add_argument('--dump-ir', action='store_true', help="Dump Command IR output")
parser.add_argument('--gen-cleanup', action='store_true', help="Generate cleanup function")
parser.add_argument('--place-location', help="Location to place command blocks", required=True)
parser.add_argument('--spawn-location', default='~ ~2 ~',
Expand Down

0 comments on commit 3bedffc

Please sign in to comment.