From d6c2f4d12360f14a6bd52ddc6af86235a5d7d257 Mon Sep 17 00:00:00 2001 From: Leeland Heins Date: Wed, 20 Feb 2019 15:57:19 -0600 Subject: [PATCH] Fix a bug for Accumulator mode identification. --- as65.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/as65.pl b/as65.pl index 1741a42..70d37d5 100644 --- a/as65.pl +++ b/as65.pl @@ -1176,6 +1176,10 @@ sub generate_Immediate { # TSB Zpg 04 sub is_Zero_Page { my ($operand, $lineno) = @_; + + # Don't mistake Accumulator mode for instructions like LSR. + return 0 if $operand =~ /^[Aa]$/; + # Parse hex if ($operand =~ /^\$[0-9a-fA-F]{0,1}[0-9a-fA-F]$/) { return 2; @@ -1279,6 +1283,10 @@ sub generate_Zero_Page { # STZ Zpg,X 74 sub is_Zero_Page_X { my ($operand, $lineno) = @_; + + # Don't mistake Accumulator mode for instructions like LSR. + return 0 if $operand =~ /^[Aa]$/; + # Parse hex if ($operand =~ /^\$[0-9a-fA-F]{0,1}[0-9a-fA-F],[Xx]$/) { return 2; @@ -1477,6 +1485,10 @@ sub generate_Zero_Page_Y { # TSB Abs 0C sub is_Absolute { my ($operand, $lineno) = @_; + + # Don't mistake Accumulator mode for instructions like LSR. + return 0 if $operand =~ /^[Aa]$/; + # Parse hex if ($operand =~ /^\$[0-9a-fA-F]{0,1}[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$/) { return 2; @@ -1688,6 +1700,10 @@ sub generate_Indirect_Absolute_X { # STZ Abs,X 9E sub is_Absolute_X { my ($operand, $lineno) = @_; + + # Don't mistake Accumulator mode for instructions like LSR. + return 0 if $operand =~ /^[Aa]$/; + # Parse hex if ($operand =~ /^\$[0-9a-fA-F]{0,1}[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F],[Xx]$/) { return 2; @@ -2292,6 +2308,7 @@ sub generate_Implied { # ROR A 6A sub is_Accumulator { my ($operand, $lineno) = @_; + if ($operand =~ /^[Aa]$/ || $operand eq '') { return 1; }