diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-04-05 22:32:10 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-04-05 22:32:10 -0500 |
commit | 8afefbfb5d3978deeddb40b03b4a5a9d1ad240f0 (patch) | |
tree | 1ed46fbf9bc7edc6bd83a50c4acfebe9c6cfa741 /bin | |
parent | 58ca360f8e09af5fa1187456a840aadf1f314152 (diff) | |
download | games-emulation-dcpu16-8afefbfb5d3978deeddb40b03b4a5a9d1ad240f0.tar.gz games-emulation-dcpu16-8afefbfb5d3978deeddb40b03b4a5a9d1ad240f0.zip |
add an assembler
Diffstat (limited to 'bin')
-rw-r--r-- | bin/dcpu16-asm | 22 |
1 files changed, 22 insertions, 0 deletions
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: $!"; |