From 8857cddc31254c8966275af94f914d0bef81ced6 Mon Sep 17 00:00:00 2001 From: Leeland Heins Date: Thu, 27 Dec 2018 19:39:22 -0600 Subject: [PATCH] Fixed bug in binary parsing --- as65.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/as65.pl b/as65.pl index 23641af..f5b4917 100644 --- a/as65.pl +++ b/as65.pl @@ -2309,10 +2309,10 @@ if (open($ifh, "<$input_file")) { $symbols{$symbol} = lc($operand); # 8 bit binary } elsif ($operand =~ /^%([01]{8})$/) { - $symbols{$symbol} = '$' . sprintf("%02x", pack("B8", $1)); + $symbols{$symbol} = '$' . sprintf("%02x", unpack('C', pack("B8", $1))); # 16 bit binary } elsif ($operand =~ /^%([01]{8})([01]{8})$/) { - $symbols{$symbol} = '$' . sprintf("%02x", pack("B8", $1)) . sprintf("%02x", pack("B8", $2)); + $symbols{$symbol} = '$' . sprintf("%02x", unpack('C', pack("B8", $1))) . sprintf("%02x", unpack('C', pack("B8", $2))); # Handle symbol } elsif ($operand =~ /^([<>]*)([A-Za-z\.\?:][A-Za-z0-9_\.\?:]*)$/) { ##FIXME -- need to handle < and > here