From 8afefbfb5d3978deeddb40b03b4a5a9d1ad240f0 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 5 Apr 2012 22:32:10 -0500 Subject: add an assembler --- bin/dcpu16-asm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bin/dcpu16-asm (limited to 'bin') diff --git a/bin/dcpu16-asm b/bin/dcpu16-asm new file mode 100644 index 0000000..1245236 --- /dev/null +++ b/bin/dcpu16-asm @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Games::Emulation::DCPU16::Assembler; +use Getopt::Long; + +my $out = 'a.out'; +GetOptions( + 'output=s' => \$out, +); + +my $file = $ARGV[0]; +open my $fh, '<', $file or die "Couldn't open $file for reading: $!"; +my $script = do { local $/; <$fh> }; + +my $assembler = Games::Emulation::DCPU16::Assembler->new; +my $bin = $assembler->assemble($script); + +open my $outfh, '>', $out or die "Couldn't open $out for writing: $!"; +print $outfh $bin; +close $outfh or die "Couldn't close $out: $!"; -- cgit v1.2.3-54-g00ecf