From 4f30cef2d36c30abe168028437dfd74c43091294 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sat, 30 Dec 2017 21:59:23 +0100 Subject: [PATCH] Implemented asm template usage statistics. Now prefer synthesis over loading. --- .../camelot64/kickc/fragment/AsmFragment.java | 10 +- .../kickc/fragment/AsmFragmentManager.java | 289 +++++------------- .../kickc/fragment/AsmFragmentSynthesis.java | 103 +++++++ .../kickc/fragment/AsmFragmentTemplate.java | 127 ++++++++ .../fragment/asm/vwuz1=vwuz1_plus_vbuc1.asm | 8 +- .../fragment/asm/vwuz1=vwuz2_plus_vbuc1.asm | 2 +- .../java/dk/camelot64/kickc/parser/KickC.g4 | 6 +- .../kickc/passes/Pass4CodeGeneration.java | 7 +- .../dk/camelot64/kickc/test/TestPrograms.java | 109 ++++++- .../camelot64/kickc/test/ref/asm-clobber.asm | 21 +- .../camelot64/kickc/test/ref/asm-clobber.log | 98 +++--- .../camelot64/kickc/test/ref/asm-clobber.sym | 12 +- .../kickc/test/ref/bitmap-bresenham.asm | 22 +- .../kickc/test/ref/bitmap-bresenham.log | 66 ++-- .../kickc/test/ref/bitmap-plotter.asm | 6 +- .../kickc/test/ref/bitmap-plotter.log | 22 +- .../dk/camelot64/kickc/test/ref/bresenham.asm | 2 +- .../dk/camelot64/kickc/test/ref/bresenham.log | 6 +- .../camelot64/kickc/test/ref/bresenhamarr.asm | 6 +- .../camelot64/kickc/test/ref/bresenhamarr.log | 26 +- .../kickc/test/ref/callconstparam.log | 2 +- .../dk/camelot64/kickc/test/ref/chargen.log | 2 +- .../dk/camelot64/kickc/test/ref/constants.asm | 2 +- .../dk/camelot64/kickc/test/ref/constants.log | 6 +- .../dk/camelot64/kickc/test/ref/halfscii.log | 2 +- .../kickc/test/ref/incrementinarray.asm | 2 +- .../kickc/test/ref/incrementinarray.log | 6 +- .../camelot64/kickc/test/ref/inline-word.asm | 2 +- .../camelot64/kickc/test/ref/inline-word.log | 6 +- .../dk/camelot64/kickc/test/ref/loopmin.log | 4 +- .../dk/camelot64/kickc/test/ref/ptrtest.asm | 2 +- .../dk/camelot64/kickc/test/ref/ptrtest.log | 6 +- .../dk/camelot64/kickc/test/ref/scroll.asm | 2 +- .../dk/camelot64/kickc/test/ref/scroll.log | 6 +- .../dk/camelot64/kickc/test/ref/scrollbig.asm | 2 +- .../dk/camelot64/kickc/test/ref/scrollbig.log | 16 +- .../camelot64/kickc/test/ref/signed-words.asm | 2 +- .../camelot64/kickc/test/ref/signed-words.log | 6 +- .../camelot64/kickc/test/ref/sinus-basic.log | 2 +- .../kickc/test/ref/sinus-sprites.asm | 2 +- .../kickc/test/ref/sinus-sprites.log | 14 +- .../kickc/test/ref/test-multiply.asm | 2 +- .../kickc/test/ref/test-multiply.log | 16 +- .../dk/camelot64/kickc/test/ref/voronoi.asm | 2 +- .../dk/camelot64/kickc/test/ref/voronoi.log | 6 +- .../camelot64/kickc/test/ref/zpparammin.asm | 4 +- .../camelot64/kickc/test/ref/zpparammin.log | 8 +- .../dk/camelot64/kickc/test/ref/zpptr.log | 2 +- 48 files changed, 640 insertions(+), 442 deletions(-) create mode 100644 src/main/java/dk/camelot64/kickc/fragment/AsmFragmentSynthesis.java create mode 100644 src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplate.java diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java index 04e60f420..4de09b6f9 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragment.java @@ -18,8 +18,8 @@ public class AsmFragment { /** The name of the fragment used in error messages. */ private String name; - /** The fragment template ASM code. */ - private KickCParser.AsmLinesContext fragmentFile; + /** The fragment template for the ASM code. */ + private AsmFragmentTemplate fragmentTemplate; /** Binding of named values in the fragment to values (constants, variables, ...) . */ private Map bindings; @@ -31,11 +31,11 @@ public class AsmFragment { Program program, String name, ScopeRef codeScopeRef, - KickCParser.AsmLinesContext fragmentFile, + AsmFragmentTemplate fragmentTemplate, Map bindings) { this.program = program; this.name = name; - this.fragmentFile = fragmentFile; + this.fragmentTemplate = fragmentTemplate; this.bindings = bindings; this.codeScopeRef = codeScopeRef; } @@ -127,7 +127,7 @@ public class AsmFragment { */ public void generate(AsmProgram asm) { AsmSequenceGenerator asmSequenceGenerator = new AsmSequenceGenerator(name, this, asm); - asmSequenceGenerator.generate(fragmentFile); + asmSequenceGenerator.generate(fragmentTemplate.getBodyAsm()); } private static class AsmSequenceGenerator extends KickCBaseVisitor { diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentManager.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentManager.java index f6a07a535..60e843c9e 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentManager.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentManager.java @@ -2,16 +2,14 @@ package dk.camelot64.kickc.fragment; import dk.camelot64.kickc.CompileLog; import dk.camelot64.kickc.asm.AsmProgram; -import dk.camelot64.kickc.parser.KickCLexer; -import dk.camelot64.kickc.parser.KickCParser; -import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.text.NumberFormat; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Provides fragments from their signature. @@ -21,68 +19,111 @@ import java.util.regex.Pattern; */ public class AsmFragmentManager { - /** Cache for fragment files. Maps signature to the parsed file. */ - private static Map fragmentFileCache = new HashMap<>(); + /** Cache for the best fragment templates. Maps signature to the best fragment template for the signature. */ + private static Map bestFragmentCache = new HashMap<>(); - private static KickCParser.AsmLinesContext UNKNOWN = new KickCParser.AsmLinesContext(null, 0); + /** Caches all asm fragment templates for all encountered signatures. */ + private static Map> fragmentTemplateCache = new LinkedHashMap<>(); + + /** Usage Statistics for fragment templates. */ + private static Map fragmentTemplateUsage = new HashMap<>(); + + /** Special singleton representing that the fragment can not be synthesized or loaded. */ + private static AsmFragmentTemplate UNKNOWN = new AsmFragmentTemplate("UNKNOWN", null); public static AsmFragment getFragment(AsmFragmentSignature signature, CompileLog log) { - KickCParser.AsmLinesContext fragmentAsmLines = fragmentFileCache.get(signature.getSignature()); - if (fragmentAsmLines == UNKNOWN) { + AsmFragmentTemplate bestTemplate = bestFragmentCache.get(signature.getSignature()); + if (bestTemplate == UNKNOWN) { if (log.isVerboseFragmentLog()) { log.append("Unknown fragment " + signature.getSignature()); } throw new UnknownFragmentException(signature.toString()); } - if (fragmentAsmLines == null) { + if (bestTemplate == null) { AsmFragmentTemplateSynthesizer synthesizer = new AsmFragmentTemplateSynthesizer(signature, log); List candidates = synthesizer.loadOrSynthesizeFragment(signature.getSignature()); if (candidates.size() == 0) { if (log.isVerboseFragmentLog()) { log.append("Unknown fragment " + signature.toString()); } - fragmentFileCache.put(signature.getSignature(), UNKNOWN); + bestFragmentCache.put(signature.getSignature(), UNKNOWN); throw new UnknownFragmentException(signature.toString()); - } double minScore = Double.MAX_VALUE; - for (AsmFragmentTemplate candidate : candidates) { - KickCParser.AsmLinesContext candidateAsmLines = - parseFragment(candidate.getBody(), signature.getSignature()); + for (AsmFragmentTemplate candidateTemplate : candidates) { AsmFragment candidateFragment = new AsmFragment( signature.getProgram(), signature.getSignature(), signature.getCodeScope(), - candidateAsmLines, + candidateTemplate, signature.getBindings()); - AsmProgram condidateAsm = new AsmProgram(); - condidateAsm.startSegment(null, signature.toString()); - candidateFragment.generate(condidateAsm); - double score = condidateAsm.getCycles(); + AsmProgram candidateAsm = new AsmProgram(); + candidateAsm.startSegment(null, signature.toString()); + candidateFragment.generate(candidateAsm); + double score = candidateAsm.getCycles(); if (score < minScore) { minScore = score; - fragmentAsmLines = candidateAsmLines; + bestTemplate = candidateTemplate; } } if (log.isVerboseFragmentLog()) { log.append("Found fragment " + signature + " score: " + minScore + " from " + candidates.size() + " candidates"); } - fragmentFileCache.put(signature.getSignature(), fragmentAsmLines); + bestFragmentCache.put(signature.getSignature(), bestTemplate); } + // Count usages + incUsage(bestTemplate); + // Return the resulting fragment instance return new AsmFragment( signature.getProgram(), signature.getSignature(), signature.getCodeScope(), - fragmentAsmLines, + bestTemplate, signature.getBindings()); } + /** + * Count one usage of ASM fragment templates - directly or through synthesis + * @param fragmentTemplate The template to increment usage of + */ + private static void incUsage(AsmFragmentTemplate fragmentTemplate) { + Integer usage = fragmentTemplateUsage.get(fragmentTemplate); + if (usage == null) { + usage = 0; + } + fragmentTemplateUsage.put(fragmentTemplate, usage + 1); + AsmFragmentTemplate subFragment = fragmentTemplate.getSubFragment(); + if (subFragment != null) { + incUsage(subFragment); + } + } + + /** + * Log the usage of all template fragemnts (both loaded and synthesized). + * @param log The compile log to add the output to + */ + public static void logUsages(CompileLog log) { + log.append("ASM FRAGMENT USAGES"); + + ArrayList signatures = new ArrayList<>(fragmentTemplateCache.keySet()); + Collections.sort(signatures); + for (String signature : signatures) { + List templates = fragmentTemplateCache.get(signature); + for (AsmFragmentTemplate template : templates) { + Integer usage = fragmentTemplateUsage.get(template); + if(usage==null) usage = 0; + log.append(String.format("%8d", usage)+" "+template.getName()); + } + } + + } + /** * Capable of creating fragments from signatures by loading them or synthesizing them from other smaller fragments. *

* The synthesizer tries a lot of different combinations and keeps track of what has already been attempted. */ - public static class AsmFragmentTemplateSynthesizer { + static class AsmFragmentTemplateSynthesizer { /** Signature of the fragment being synthesized. */ private AsmFragmentSignature signature; @@ -90,27 +131,16 @@ public class AsmFragmentManager { /** The log. */ private CompileLog log; - /** Caches all asm fragment templates for all encountered signatures. */ - private static Map> templateCache = new LinkedHashMap<>(); - - public AsmFragmentTemplateSynthesizer(AsmFragmentSignature signature, CompileLog log) { + AsmFragmentTemplateSynthesizer(AsmFragmentSignature signature, CompileLog log) { this.signature = signature; this.log = log; } - public List loadOrSynthesizeFragment(String signature) { - if (templateCache.get(signature) != null) { - return templateCache.get(signature); + List loadOrSynthesizeFragment(String signature) { + if (fragmentTemplateCache.get(signature) != null) { + return fragmentTemplateCache.get(signature); } List candidates = new ArrayList<>(); - // Load the fragment from disk - CharStream fragmentCharStream = loadFragment(signature); - if (fragmentCharStream != null) { - candidates.add(new AsmFragmentTemplate(signature, fragmentCharStream.toString())); - if (log.isVerboseFragmentLog()) { - log.append("Finding fragment " + this.signature.getSignature() + " - Successfully loaded fragment " + signature); - } - } // Synthesize the fragment from other fragments List synths = getFragmentSyntheses(); for (AsmFragmentSynthesis synth : synths) { @@ -122,156 +152,17 @@ public class AsmFragmentManager { candidates.addAll(synthesized); } } - templateCache.put(signature, candidates); - return candidates; - } - } - - /** - * An ASM fragment template usable for generating KickAssembler code for different bindings. - * The AsmFragmentTemplateSynthesizer can generate multiple different templates usable for a specific fragment signature. - */ - public static class AsmFragmentTemplate { - - /** The fragment template signature name. */ - private String signature; - - /** The fragment template body */ - private String body; - - /** true if the fragment was loaded from disk. */ - boolean loaded; - - /** The synthesis that created the fragment. null if the fragment template was loaded. */ - private AsmFragmentSynthesis synthesis; - - /** The sub fragment template that the synthesis modified to create this. null if the fragment template was loaded. */ - private AsmFragmentTemplate subFragment; - - public AsmFragmentTemplate(String signature, String body) { - this.signature = signature; - this.body = body; - this.loaded = true; - } - - public AsmFragmentTemplate(String signature, String body, AsmFragmentSynthesis synthesis, AsmFragmentTemplate subFragment) { - this.signature = signature; - this.body = body; - this.synthesis = synthesis; - this.subFragment = subFragment; - this.loaded = false; - } - - public String getSignature() { - return signature; - } - - public String getBody() { - return body; - } - - public boolean isLoaded() { - return loaded; - } - - public AsmFragmentSynthesis getSynthesis() { - return synthesis; - } - - public AsmFragmentTemplate getSubFragment() { - return subFragment; - } - } - - /** AsmFragment synthesis mechanism based on matching fragment signature and reusing another fragment with added prefix/postfix and some bind-mappings */ - private static class AsmFragmentSynthesis { - - private String sigMatch; - private String sigAvoid; - private String asmPrefix; - private String sigReplace; - private String asmPostfix; - private Map bindMappings; - private boolean mapSignature; - private String subSignature; - - public AsmFragmentSynthesis(String sigMatch, String sigAvoid, String asmPrefix, String sigReplace, String asmPostfix, Map bindMappings, boolean mapSignature) { - this.sigMatch = sigMatch; - this.sigAvoid = sigAvoid; - this.asmPrefix = asmPrefix; - this.sigReplace = sigReplace; - this.asmPostfix = asmPostfix; - this.bindMappings = bindMappings; - this.mapSignature = mapSignature; - } - - public AsmFragmentSynthesis(String sigMatch, String sigAvoid, String asmPrefix, String sigReplace, String asmPostfix, Map bindMappings) { - this(sigMatch, sigAvoid, asmPrefix, sigReplace, asmPostfix, bindMappings, true); - } - - public List synthesize(String signature, AsmFragmentTemplateSynthesizer synthesizer) { - ArrayList candidates = new ArrayList<>(); - if (signature.matches(sigMatch)) { - if (sigAvoid == null || !signature.matches(sigAvoid)) { - subSignature = regexpRewriteSignature(signature, sigMatch, sigReplace); - if (mapSignature && bindMappings != null) { - // When mapping the signature we do the map replacement in the signature - for (String bound : bindMappings.keySet()) { - subSignature = subSignature.replace(bound, bindMappings.get(bound)); - } - } - List subFragmentTemplates = synthesizer.loadOrSynthesizeFragment(subSignature); - for (AsmFragmentTemplate subFragmentTemplate : subFragmentTemplates) { - if (subFragmentTemplate != null) { - StringBuilder newFragment = new StringBuilder(); - if (asmPrefix != null) { - newFragment.append(asmPrefix); - } - String subFragment = subFragmentTemplate.getBody(); - if (bindMappings != null) { - if (mapSignature) { - // When mapping the signature we do the reverse replacement in the ASM - List reverse = new ArrayList<>(bindMappings.keySet()); - Collections.reverse(reverse); - for (String bound : reverse) { - subFragment = subFragment.replace("{" + bindMappings.get(bound) + "}", "{" + bound + "}"); - } - } else { - // When not mapping the signature we do the replacement directly in the ASM - for (String bound : bindMappings.keySet()) { - subFragment = subFragment.replace("{" + bound + "}", "{" + bindMappings.get(bound) + "}"); - } - } - } - newFragment.append(subFragment); - if (asmPostfix != null) { - newFragment.append("\n"); - newFragment.append(asmPostfix); - } - candidates.add(new AsmFragmentTemplate(signature, newFragment.toString(), this, subFragmentTemplate)); - } - } + // Load the fragment from disk + CharStream fragmentCharStream = loadFragment(signature); + if (fragmentCharStream != null) { + candidates.add(new AsmFragmentTemplate(signature, fragmentCharStream.toString())); + if (log.isVerboseFragmentLog()) { + log.append("Finding fragment " + this.signature.getSignature() + " - Successfully loaded fragment " + signature); } } + fragmentTemplateCache.put(signature, candidates); return candidates; } - - public String getSubSignature() { - return subSignature; - } - - } - - - private static String regexpRewriteSignature(String signature, String match, String replace) { - Pattern p = Pattern.compile(match); - Matcher m = p.matcher(signature); - String output = signature; - if (m.find()) { - // getReplacement first number with "number" and second number with the first - output = m.replaceAll(replace); - } - return output; } @@ -295,34 +186,11 @@ public class AsmFragmentManager { } } - /** - * Parse an ASM fragment. - * - * @param fragmentCharStream The stream containing the fragment syntax - * @param fragmentFileName The filename (used in error messages) - * @return The parsed fragment ready for generating - * @throws IOException if the parsing/loading fails - */ - public static KickCParser.AsmLinesContext parseFragment(String fragmentBody, final String fragmentFileName) { - CodePointCharStream fragmentCharStream = CharStreams.fromString(fragmentBody); - KickCLexer kickCLexer = new KickCLexer(fragmentCharStream); - KickCParser kickCParser = new KickCParser(new CommonTokenStream(kickCLexer)); - kickCParser.addErrorListener(new BaseErrorListener() { - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { - throw new RuntimeException("Error parsing fragment " + fragmentFileName + "\n - Line: " + line + "\n - Message: " + msg); - } - }); - kickCParser.setBuildParseTree(true); - KickCParser.AsmFileContext asmFile = kickCParser.asmFile(); - return asmFile.asmLines(); - } - public static class UnknownFragmentException extends RuntimeException { private String fragmentSignature; - public UnknownFragmentException(String signature) { + UnknownFragmentException(String signature) { super("Fragment not found " + signature + ".asm"); this.fragmentSignature = signature; } @@ -533,6 +401,7 @@ public class AsmFragmentManager { synths.add(new AsmFragmentSynthesis("(.*)=p..([cz].)_(plus|minus|bor|bxor)_(.*)", null, null, "$1=vwu$2_$3_$4", null, null)); synths.add(new AsmFragmentSynthesis("p..([cz].)=(.*)_(sethi|setlo|plus|minus)_(.*)", null, null, "vwu$1=$2_$3_$4", null, null)); synths.add(new AsmFragmentSynthesis("(.*)=p..([cz].)_(sethi|setlo|plus|minus)_(.*)", null, null, "$1=vwu$2_$3_$4", null, null)); + return synths; } diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentSynthesis.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentSynthesis.java new file mode 100644 index 000000000..1f1f1ac3a --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentSynthesis.java @@ -0,0 +1,103 @@ +package dk.camelot64.kickc.fragment; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** AsmFragment synthesis mechanism based on matching fragment signature and reusing another fragment with added prefix/postfix and some bind-mappings */ +class AsmFragmentSynthesis { + + private String sigMatch; + private String sigAvoid; + private String asmPrefix; + private String sigReplace; + private String asmPostfix; + private Map bindMappings; + private boolean mapSignature; + private String subSignature; + + AsmFragmentSynthesis(String sigMatch, String sigAvoid, String asmPrefix, String sigReplace, String asmPostfix, Map bindMappings, boolean mapSignature) { + this.sigMatch = sigMatch; + this.sigAvoid = sigAvoid; + this.asmPrefix = asmPrefix; + this.sigReplace = sigReplace; + this.asmPostfix = asmPostfix; + this.bindMappings = bindMappings; + this.mapSignature = mapSignature; + } + + public AsmFragmentSynthesis(String sigMatch, String sigAvoid, String asmPrefix, String sigReplace, String asmPostfix, Map bindMappings) { + this(sigMatch, sigAvoid, asmPrefix, sigReplace, asmPostfix, bindMappings, true); + } + + public String getName() { + return sigMatch + (sigAvoid == null ? "" : ("/" + sigAvoid)); + } + + public List synthesize(String signature, AsmFragmentManager.AsmFragmentTemplateSynthesizer synthesizer) { + ArrayList candidates = new ArrayList<>(); + if (signature.matches(sigMatch)) { + if (sigAvoid == null || !signature.matches(sigAvoid)) { + subSignature = regexpRewriteSignature(signature, sigMatch, sigReplace); + if (mapSignature && bindMappings != null) { + // When mapping the signature we do the map replacement in the signature + for (String bound : bindMappings.keySet()) { + subSignature = subSignature.replace(bound, bindMappings.get(bound)); + } + } + List subFragmentTemplates = synthesizer.loadOrSynthesizeFragment(subSignature); + for (AsmFragmentTemplate subFragmentTemplate : subFragmentTemplates) { + if (subFragmentTemplate != null) { + StringBuilder newFragment = new StringBuilder(); + if (asmPrefix != null) { + newFragment.append(asmPrefix); + } + String subFragment = subFragmentTemplate.getBody(); + if (bindMappings != null) { + if (mapSignature) { + // When mapping the signature we do the reverse replacement in the ASM + List reverse = new ArrayList<>(bindMappings.keySet()); + Collections.reverse(reverse); + for (String bound : reverse) { + subFragment = subFragment.replace("{" + bindMappings.get(bound) + "}", "{" + bound + "}"); + } + } else { + // When not mapping the signature we do the replacement directly in the ASM + for (String bound : bindMappings.keySet()) { + subFragment = subFragment.replace("{" + bound + "}", "{" + bindMappings.get(bound) + "}"); + } + } + } + newFragment.append(subFragment); + if (asmPostfix != null) { + newFragment.append("\n"); + newFragment.append(asmPostfix); + } + candidates.add(new AsmFragmentTemplate(signature, newFragment.toString(), this, subFragmentTemplate)); + } + } + } + } + return candidates; + } + + public String getSubSignature() { + return subSignature; + } + + static String regexpRewriteSignature(String signature, String match, String replace) { + Pattern p = Pattern.compile(match); + Matcher m = p.matcher(signature); + String output = signature; + if (m.find()) { + // getReplacement first number with "number" and second number with the first + output = m.replaceAll(replace); + } + return output; + } + + +} diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplate.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplate.java new file mode 100644 index 000000000..4e7767a48 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplate.java @@ -0,0 +1,127 @@ +package dk.camelot64.kickc.fragment; + +import dk.camelot64.kickc.parser.KickCLexer; +import dk.camelot64.kickc.parser.KickCParser; +import org.antlr.v4.runtime.*; + +/** + * An ASM fragment template usable for generating KickAssembler code for different bindings. + * The AsmFragmentTemplateSynthesizer can generate multiple different templates usable for a specific fragment signature. + */ +public class AsmFragmentTemplate { + + /** The fragment template signature name. */ + private String signature; + + /** The fragment template body */ + private String body; + + /** The parsed ASM lines. Initially null. Will be non-null, is the template is ever used to generate ASM code. */ + private KickCParser.AsmLinesContext bodyAsm; + + /** true if the fragment was loaded from disk. */ + boolean loaded; + + /** The synthesis that created the fragment. null if the fragment template was loaded. */ + private AsmFragmentSynthesis synthesis; + + /** The sub fragment template that the synthesis modified to create this. null if the fragment template was loaded. */ + private AsmFragmentTemplate subFragment; + + public AsmFragmentTemplate(String signature, String body) { + this.signature = signature; + this.body = body; + this.loaded = true; + } + + AsmFragmentTemplate(String signature, String body, AsmFragmentSynthesis synthesis, AsmFragmentTemplate subFragment) { + this.signature = signature; + this.body = body; + this.synthesis = synthesis; + this.subFragment = subFragment; + this.loaded = false; + } + + /** + * Creates an inline ASM fragment template + * + * @param bodyLines Parsed ASM body + */ + public AsmFragmentTemplate(KickCParser.AsmLinesContext bodyLines) { + this.signature = "--inline--"; + this.bodyAsm = bodyLines; + } + + public String getSignature() { + return signature; + } + + public String getBody() { + return body; + } + + public KickCParser.AsmLinesContext getBodyAsm() { + if (bodyAsm == null) { + bodyAsm = parseBody(body, signature); + } + return bodyAsm; + } + + /** + * Parse an ASM fragment. + * + * @param fragmentBody The stream containing the fragment syntax + * @param fragmentFileName The filename (used in error messages) + * @return The parsed fragment ready for generating + */ + private static KickCParser.AsmLinesContext parseBody(String fragmentBody, final String fragmentFileName) { + CodePointCharStream fragmentCharStream = CharStreams.fromString(fragmentBody); + KickCLexer kickCLexer = new KickCLexer(fragmentCharStream); + KickCParser kickCParser = new KickCParser(new CommonTokenStream(kickCLexer)); + kickCParser.addErrorListener(new BaseErrorListener() { + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { + throw new RuntimeException("Error parsing fragment " + fragmentFileName + "\n - Line: " + line + "\n - Message: " + msg); + } + }); + kickCParser.setBuildParseTree(true); + KickCParser.AsmFileContext asmFile = kickCParser.asmFile(); + return asmFile.asmLines(); + } + + + public boolean isLoaded() { + return loaded; + } + + public AsmFragmentSynthesis getSynthesis() { + return synthesis; + } + + public AsmFragmentTemplate getSubFragment() { + return subFragment; + } + + public String getName() { + StringBuilder name = new StringBuilder(); + name.append(signature); + if (synthesis != null) { + name.append(" < "); + name.append(subFragment.getName()); + } + return name.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AsmFragmentTemplate that = (AsmFragmentTemplate) o; + return getName().equals(that.getName()); + } + + @Override + public int hashCode() { + return getName().hashCode(); + } +} diff --git a/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz1_plus_vbuc1.asm b/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz1_plus_vbuc1.asm index 6e559277d..feca52a39 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz1_plus_vbuc1.asm +++ b/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz1_plus_vbuc1.asm @@ -1,7 +1,7 @@ lda {z1} clc -adc #<{c1} +adc #{c1} sta {z1} -bcc !+ -inc {z1}+1 -!: +lda {z1}+1 +adc #0 +sta {z1}+1 \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz2_plus_vbuc1.asm b/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz2_plus_vbuc1.asm index b1203786a..2e9e69bc1 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz2_plus_vbuc1.asm +++ b/src/main/java/dk/camelot64/kickc/fragment/asm/vwuz1=vwuz2_plus_vbuc1.asm @@ -1,6 +1,6 @@ lda {z2} clc -adc #<{c1} +adc #{c1} sta {z1} lda {z2}+1 adc #0 diff --git a/src/main/java/dk/camelot64/kickc/parser/KickC.g4 b/src/main/java/dk/camelot64/kickc/parser/KickC.g4 index 8c79c93e2..8013cab04 100644 --- a/src/main/java/dk/camelot64/kickc/parser/KickC.g4 +++ b/src/main/java/dk/camelot64/kickc/parser/KickC.g4 @@ -6,7 +6,7 @@ file ; asmFile - : asmLines EOF + : bodyAsm EOF ; importSeq @@ -58,7 +58,7 @@ stmt | 'do' stmt 'while' '(' expr ')' ';' #stmtDoWhile | 'for' '(' forDeclaration? forIteration ')' stmt #stmtFor | 'return' expr? ';' #stmtReturn - | 'asm' '{' asmLines '}' #stmtAsm + | 'asm' '{' bodyAsm '}' #stmtAsm ; forDeclaration @@ -109,7 +109,7 @@ parameterList : expr (',' expr)* ; -asmLines +bodyAsm : asmLine* ; diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index 57610f02a..4bc5edf2d 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -1,10 +1,7 @@ package dk.camelot64.kickc.passes; import dk.camelot64.kickc.asm.*; -import dk.camelot64.kickc.fragment.AsmFormat; -import dk.camelot64.kickc.fragment.AsmFragment; -import dk.camelot64.kickc.fragment.AsmFragmentManager; -import dk.camelot64.kickc.fragment.AsmFragmentSignature; +import dk.camelot64.kickc.fragment.*; import dk.camelot64.kickc.model.*; import java.util.*; @@ -276,7 +273,7 @@ public class Pass4CodeGeneration { } else if (statement instanceof StatementAsm) { StatementAsm statementAsm = (StatementAsm) statement; HashMap bindings = new HashMap<>(); - AsmFragment asmFragment = new AsmFragment(program, "inline", block.getScope(), statementAsm.getAsmLines(), bindings); + AsmFragment asmFragment = new AsmFragment(program, "inline", block.getScope(), new AsmFragmentTemplate(statementAsm.getAsmLines()), bindings); asmFragment.generate(asm); } else { throw new RuntimeException("Statement not supported " + statement); diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 0777fb518..6cbcca411 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -1,17 +1,23 @@ package dk.camelot64.kickc.test; +import dk.camelot64.kickc.CompileLog; import dk.camelot64.kickc.Compiler; +import dk.camelot64.kickc.fragment.AsmFragmentManager; import dk.camelot64.kickc.model.CompileError; import dk.camelot64.kickc.model.Program; -import junit.framework.TestCase; +import org.junit.AfterClass; +import org.junit.Test; import java.io.IOException; import java.net.URISyntaxException; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertTrue; + /** * Compile a number of source files and compare the resulting assembler with expected output */ -public class TestPrograms extends TestCase { +public class TestPrograms { ReferenceHelper helper; @@ -22,351 +28,444 @@ public class TestPrograms extends TestCase { helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/"); } + @AfterClass + public static void tearDown() throws Exception { + CompileLog log = new CompileLog(); + log.setSysOut(true); + AsmFragmentManager.logUsages(log); + } + + @Test public void testMemAlignment() throws IOException, URISyntaxException { compileAndCompare("mem-alignment"); } + @Test public void testMultiply() throws IOException, URISyntaxException { compileAndCompare("test-multiply"); } + @Test public void testArraysInit() throws IOException, URISyntaxException { compileAndCompare("arrays-init"); } + @Test public void testConstantStringConcat() throws IOException, URISyntaxException { compileAndCompare("constant-string-concat"); } + @Test public void testTrueInlineWords() throws IOException, URISyntaxException { compileAndCompare("true-inline-words"); } + @Test public void testIncrementInArray() throws IOException, URISyntaxException { compileAndCompare("incrementinarray"); } + @Test public void testForIncrementAssign() throws IOException, URISyntaxException { compileAndCompare("forincrementassign"); } + @Test public void testConstants() throws IOException, URISyntaxException { compileAndCompare("constants"); } + @Test public void testInlineAssignment() throws IOException, URISyntaxException { compileAndCompare("inline-assignment"); } + @Test public void testInlineWord() throws IOException, URISyntaxException { compileAndCompare("inline-word"); } + @Test public void testSignedWords() throws IOException, URISyntaxException { compileAndCompare("signed-words"); } + @Test public void testSinusSprites() throws IOException, URISyntaxException { compileAndCompare("sinus-sprites"); } + @Test public void testConstantAbsMin() throws IOException, URISyntaxException { compileAndCompare("constabsmin"); } + @Test public void testBasicFloats() throws IOException, URISyntaxException { compileAndCompare("sinus-basic"); } + @Test public void testDoubleImport() throws IOException, URISyntaxException { compileAndCompare("double-import"); } + @Test public void testImporting() throws IOException, URISyntaxException { compileAndCompare("importing"); } + @Test public void testUnusedVars() throws IOException, URISyntaxException { compileAndCompare("unused-vars"); } + @Test public void testFillscreen() throws IOException, URISyntaxException { compileAndCompare("fillscreen"); } + @Test public void testLiverangeCallProblem() throws IOException, URISyntaxException { compileAndCompare("liverange-call-problem"); } + @Test public void testPrintProblem() throws IOException, URISyntaxException { compileAndCompare("print-problem"); } + @Test public void testPrintMsg() throws IOException, URISyntaxException { compileAndCompare("printmsg"); } + @Test public void testUnusedMethod() throws IOException, URISyntaxException { compileAndCompare("unused-method"); } + @Test public void testInlineString() throws IOException, URISyntaxException { compileAndCompare("inline-string"); } + @Test public void testLocalString() throws IOException, URISyntaxException { compileAndCompare("local-string"); } + @Test public void testInlineArrayProblem() throws IOException, URISyntaxException { - String filename = "inlinearrayproblem"; - compileAndCompare(filename); + compileAndCompare("inlinearrayproblem"); } + @Test public void testImmZero() throws IOException, URISyntaxException { compileAndCompare("immzero"); } + @Test public void testWordExpr() throws IOException, URISyntaxException { compileAndCompare("wordexpr"); } + @Test public void testZpptr() throws IOException, URISyntaxException { compileAndCompare("zpptr"); } + @Test public void testCasting() throws IOException, URISyntaxException { compileAndCompare("casting"); } + @Test public void testSignedBytes() throws IOException, URISyntaxException { compileAndCompare("signed-bytes"); } + @Test public void testScrollBig() throws IOException, URISyntaxException { compileAndCompare("scrollbig"); } + @Test public void testPtrComplex() throws IOException, URISyntaxException { compileAndCompare("ptr-complex"); } + @Test public void testIncD020() throws IOException, URISyntaxException { compileAndCompare("incd020"); } + @Test public void testOverlapAllocation2() throws IOException, URISyntaxException { compileAndCompare("overlap-allocation-2"); } + @Test public void testOverlapAllocation() throws IOException, URISyntaxException { compileAndCompare("overlap-allocation"); } + @Test public void testBitmapBresenham() throws IOException, URISyntaxException { compileAndCompare("bitmap-bresenham"); } + @Test public void testAsmClobber() throws IOException, URISyntaxException { compileAndCompare("asm-clobber"); } + @Test public void testInlineAsm() throws IOException, URISyntaxException { compileAndCompare("inline-asm"); } + @Test public void testChargen() throws IOException, URISyntaxException { compileAndCompare("chargen"); } + @Test public void testBitmapPlotter() throws IOException, URISyntaxException { compileAndCompare("bitmap-plotter"); } + @Test public void testConstIdentification() throws IOException, URISyntaxException { compileAndCompare("const-identification"); } + @Test public void testCallConstParam() throws IOException, URISyntaxException { compileAndCompare("callconstparam"); } + @Test public void testScrollClobber() throws IOException, URISyntaxException { compileAndCompare("scroll-clobber"); } + @Test public void testHalfscii() throws IOException, URISyntaxException { compileAndCompare("halfscii"); } + @Test public void testLiterals() throws IOException, URISyntaxException { compileAndCompare("literals"); } + @Test public void testScroll() throws IOException, URISyntaxException { compileAndCompare("scroll"); } + @Test public void testConstantMin() throws IOException, URISyntaxException { compileAndCompare("constantmin"); } + @Test public void testLiveRange() throws IOException, URISyntaxException { compileAndCompare("liverange"); } + @Test public void testZpParamMin() throws IOException, URISyntaxException { compileAndCompare("zpparammin"); } + @Test public void testInMemArray() throws IOException, URISyntaxException { compileAndCompare("inmemarray"); } + @Test public void testInMemConstArray() throws IOException, URISyntaxException { compileAndCompare("inmem-const-array"); } + @Test public void testInMemString() throws IOException, URISyntaxException { compileAndCompare("inmemstring"); } + @Test public void testVoronoi() throws IOException, URISyntaxException { compileAndCompare("voronoi"); } + @Test public void testFlipper() throws IOException, URISyntaxException { compileAndCompare("flipper-rex2"); } + @Test public void testBresenham() throws IOException, URISyntaxException { compileAndCompare("bresenham"); } + @Test public void testBresenhamArr() throws IOException, URISyntaxException { compileAndCompare("bresenhamarr"); } + @Test public void testIterArray() throws IOException, URISyntaxException { compileAndCompare("iterarray"); } + @Test public void testLoopMin() throws IOException, URISyntaxException { compileAndCompare("loopmin"); } + @Test public void testSumMin() throws IOException, URISyntaxException { compileAndCompare("summin"); } + @Test public void testLoopSplit() throws IOException, URISyntaxException { compileAndCompare("loopsplit"); } + @Test public void testLoopNest() throws IOException, URISyntaxException { compileAndCompare("loopnest"); } - public void testLoopNest2() throws IOException, URISyntaxException { + @Test + public void testLoopNest2() throws IOException, URISyntaxException { compileAndCompare("loopnest2"); } + @Test public void testFibMem() throws IOException, URISyntaxException { compileAndCompare("fibmem"); } + @Test public void testPtrTest() throws IOException, URISyntaxException { compileAndCompare("ptrtest"); } + @Test public void testPtrTestMin() throws IOException, URISyntaxException { compileAndCompare("ptrtestmin"); } + @Test public void testUseGlobal() throws IOException, URISyntaxException { compileAndCompare("useglobal"); } + @Test public void testModGlobal() throws IOException, URISyntaxException { compileAndCompare("modglobal"); } + @Test public void testModGlobalMin() throws IOException, URISyntaxException { compileAndCompare("modglobalmin"); } + @Test public void testIfMin() throws IOException, URISyntaxException { compileAndCompare("ifmin"); } + @Test public void testForClassicMin() throws IOException, URISyntaxException { compileAndCompare("forclassicmin"); } + @Test public void testForRangeMin() throws IOException, URISyntaxException { compileAndCompare("forrangemin"); } + @Test public void testAssignConst() throws IOException, URISyntaxException { assertError("assign-const", "Constants can not be modified"); } + @Test public void testStmtOutsideMethod() throws IOException, URISyntaxException { assertError("stmt-outside-method", "Error parsing"); } + @Test public void testUseUndeclared() throws IOException, URISyntaxException { assertError("useundeclared", "Unknown variable"); } + @Test public void testUseUninitialized() throws IOException, URISyntaxException { assertError("useuninitialized", "Variable used before being defined"); } + @Test public void testTypeMismatch() throws IOException, URISyntaxException { assertError("typemismatch", "Type mismatch"); } + @Test public void testToManyParams() throws IOException, URISyntaxException { assertError("tomanyparams", "Wrong number of parameters in call"); } + @Test public void testToFewParams() throws IOException, URISyntaxException { assertError("tofewparams", "Wrong number of parameters in call"); } + @Test public void testNoReturn() throws IOException, URISyntaxException { assertError("noreturn", "Method must end with a return statement"); } + @Test public void testProcedureNotFound() throws IOException, URISyntaxException { assertError("procedurenotfound", "Called procedure not found"); } + @Test public void testIllegalLValue() throws IOException, URISyntaxException { assertError("illegallvalue", "LValue is illegal"); } + @Test public void testInvalidConstType() throws IOException, URISyntaxException { assertError("invalid-consttype", "Constant variable has a non-matching type"); } + @Test public void testValueListError() throws IOException, URISyntaxException { assertError("valuelist-error", "Value list not resolved to word constructor"); } + @Test public void testArrayUninitialized() throws IOException, URISyntaxException { assertError("array-uninitialized", "Cannot determine array size."); } + @Test public void testArrayLengthMismatch() throws IOException, URISyntaxException { assertError("array-length-mismatch", "Array length mismatch"); } + @Test public void testStringLengthMismatch() throws IOException, URISyntaxException { assertError("string-length-mismatch", "Array length mismatch"); } + @Test public void testIllegalAlignment() throws IOException, URISyntaxException { assertError("illegal-alignment", "Cannot align variable"); } diff --git a/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.asm b/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.asm index 69344a6a5..a584294c9 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.asm @@ -4,7 +4,7 @@ .const SCREEN = $400 jsr main main: { - .label l = 2 + .label k = 2 ldx #0 b1: lda #0 @@ -17,21 +17,22 @@ main: { inx cpx #$65 bne b1 - ldy #0 - b3: lda #0 - sta l + sta k + b3: + ldy #0 b4: eor #$55 tax - lda l - sta SCREEN,y - inc l - lda l - cmp #$65 - bne b4 + tya + ldx k + sta SCREEN,x iny cpy #$65 + bne b4 + inc k + lda k + cmp #$65 bne b3 rts } diff --git a/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.log b/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.log index 86240dd99..16948c89c 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.log @@ -594,11 +594,11 @@ REGISTER UPLIFT SCOPES Uplift Scope [main] 303: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 252.5: zp ZP_BYTE:5 [ main::l#2 main::l#1 ] 41.1: zp ZP_BYTE:2 [ main::i#4 main::i#1 ] 37: zp ZP_BYTE:4 [ main::k#4 main::k#1 ] Uplift Scope [] -Uplifting [main] best 6638 combination reg byte a [ main::j#2 main::j#1 ] zp ZP_BYTE:5 [ main::l#2 main::l#1 ] reg byte x [ main::i#4 main::i#1 ] reg byte y [ main::k#4 main::k#1 ] -Uplifting [] best 6638 combination -Attempting to uplift remaining variables inzp ZP_BYTE:5 [ main::l#2 main::l#1 ] -Uplifting [main] best 6638 combination zp ZP_BYTE:5 [ main::l#2 main::l#1 ] -Allocated (was zp ZP_BYTE:5) zp ZP_BYTE:2 [ main::l#2 main::l#1 ] +Uplifting [main] best 6028 combination reg byte a [ main::j#2 main::j#1 ] reg byte y [ main::l#2 main::l#1 ] reg byte x [ main::i#4 main::i#1 ] zp ZP_BYTE:4 [ main::k#4 main::k#1 ] +Uplifting [] best 6028 combination +Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::k#4 main::k#1 ] +Uplifting [main] best 6028 combination zp ZP_BYTE:4 [ main::k#4 main::k#1 ] +Allocated (was zp ZP_BYTE:4) zp ZP_BYTE:2 [ main::k#4 main::k#1 ] ASSEMBLER BEFORE OPTIMIZATION //SEG0 Basic Upstart @@ -625,7 +625,7 @@ bend_from_b1: bend: //SEG9 main main: { - .label l = 2 + .label k = 2 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] b1_from_main: //SEG11 [5] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 @@ -666,8 +666,9 @@ main: { bne b1_from_b5 //SEG26 [12] phi from main::@5 to main::@3 [phi:main::@5->main::@3] b3_from_b5: - //SEG27 [12] phi (byte) main::k#4 = (byte/signed byte/word/signed word) 0 [phi:main::@5->main::@3#0] -- vbuyy=vbuc1 - ldy #0 + //SEG27 [12] phi (byte) main::k#4 = (byte/signed byte/word/signed word) 0 [phi:main::@5->main::@3#0] -- vbuz1=vbuc1 + lda #0 + sta k jmp b3 //SEG28 [12] phi from main::@7 to main::@3 [phi:main::@7->main::@3] b3_from_b7: @@ -677,9 +678,8 @@ main: { b3: //SEG31 [13] phi from main::@3 to main::@4 [phi:main::@3->main::@4] b4_from_b3: - //SEG32 [13] phi (byte) main::l#2 = (byte/signed byte/word/signed word) 0 [phi:main::@3->main::@4#0] -- vbuz1=vbuc1 - lda #0 - sta l + //SEG32 [13] phi (byte) main::l#2 = (byte/signed byte/word/signed word) 0 [phi:main::@3->main::@4#0] -- vbuyy=vbuc1 + ldy #0 jmp b4 //SEG33 [13] phi from main::@4 to main::@4 [phi:main::@4->main::@4] b4_from_b4: @@ -690,22 +690,23 @@ main: { //SEG36 asm { eor#$55 tax } eor #$55 tax - //SEG37 [15] *((const byte*) SCREEN#0 + (byte) main::k#4) ← (byte) main::l#2 [ main::k#4 main::l#2 ] ( main:2 [ main::k#4 main::l#2 ] ) -- pbuc1_derefidx_vbuyy=vbuz1 - lda l - sta SCREEN,y - //SEG38 [16] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuz1=_inc_vbuz1 - inc l - //SEG39 [17] if((byte) main::l#1!=(byte/signed byte/word/signed word) 101) goto main::@4 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuz1_neq_vbuc1_then_la1 - lda l - cmp #$65 + //SEG37 [15] *((const byte*) SCREEN#0 + (byte) main::k#4) ← (byte) main::l#2 [ main::k#4 main::l#2 ] ( main:2 [ main::k#4 main::l#2 ] ) -- pbuc1_derefidx_vbuz1=vbuyy + tya + ldx k + sta SCREEN,x + //SEG38 [16] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuyy=_inc_vbuyy + iny + //SEG39 [17] if((byte) main::l#1!=(byte/signed byte/word/signed word) 101) goto main::@4 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuyy_neq_vbuc1_then_la1 + cpy #$65 bne b4_from_b4 jmp b7 //SEG40 main::@7 b7: - //SEG41 [18] (byte) main::k#1 ← ++ (byte) main::k#4 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuyy=_inc_vbuyy - iny - //SEG42 [19] if((byte) main::k#1!=(byte/signed byte/word/signed word) 101) goto main::@3 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuyy_neq_vbuc1_then_la1 - cpy #$65 + //SEG41 [18] (byte) main::k#1 ← ++ (byte) main::k#4 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuz1=_inc_vbuz1 + inc k + //SEG42 [19] if((byte) main::k#1!=(byte/signed byte/word/signed word) 101) goto main::@3 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuz1_neq_vbuc1_then_la1 + lda k + cmp #$65 bne b3_from_b7 jmp breturn //SEG43 main::@return @@ -775,20 +776,20 @@ FINAL SYMBOL TABLE (byte) main::j#1 reg byte a 151.5 (byte) main::j#2 reg byte a 151.5 (byte) main::k -(byte) main::k#1 reg byte y 16.5 -(byte) main::k#4 reg byte y 20.499999999999996 +(byte) main::k#1 k zp ZP_BYTE:2 16.5 +(byte) main::k#4 k zp ZP_BYTE:2 20.499999999999996 (byte) main::l -(byte) main::l#1 l zp ZP_BYTE:2 151.5 -(byte) main::l#2 l zp ZP_BYTE:2 101.0 +(byte) main::l#1 reg byte y 151.5 +(byte) main::l#2 reg byte y 101.0 reg byte x [ main::i#4 main::i#1 ] reg byte a [ main::j#2 main::j#1 ] -reg byte y [ main::k#4 main::k#1 ] -zp ZP_BYTE:2 [ main::l#2 main::l#1 ] +zp ZP_BYTE:2 [ main::k#4 main::k#1 ] +reg byte y [ main::l#2 main::l#1 ] FINAL ASSEMBLER -Score: 4682 +Score: 4072 //SEG0 Basic Upstart .pc = $801 "Basic" @@ -806,7 +807,7 @@ Score: 4682 //SEG8 @end //SEG9 main main: { - .label l = 2 + .label k = 2 //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] //SEG11 [5] phi (byte) main::i#4 = (byte/signed byte/word/signed word) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 ldx #0 @@ -836,16 +837,16 @@ main: { cpx #$65 bne b1 //SEG26 [12] phi from main::@5 to main::@3 [phi:main::@5->main::@3] - //SEG27 [12] phi (byte) main::k#4 = (byte/signed byte/word/signed word) 0 [phi:main::@5->main::@3#0] -- vbuyy=vbuc1 - ldy #0 + //SEG27 [12] phi (byte) main::k#4 = (byte/signed byte/word/signed word) 0 [phi:main::@5->main::@3#0] -- vbuz1=vbuc1 + lda #0 + sta k //SEG28 [12] phi from main::@7 to main::@3 [phi:main::@7->main::@3] //SEG29 [12] phi (byte) main::k#4 = (byte) main::k#1 [phi:main::@7->main::@3#0] -- register_copy //SEG30 main::@3 b3: //SEG31 [13] phi from main::@3 to main::@4 [phi:main::@3->main::@4] - //SEG32 [13] phi (byte) main::l#2 = (byte/signed byte/word/signed word) 0 [phi:main::@3->main::@4#0] -- vbuz1=vbuc1 - lda #0 - sta l + //SEG32 [13] phi (byte) main::l#2 = (byte/signed byte/word/signed word) 0 [phi:main::@3->main::@4#0] -- vbuyy=vbuc1 + ldy #0 //SEG33 [13] phi from main::@4 to main::@4 [phi:main::@4->main::@4] //SEG34 [13] phi (byte) main::l#2 = (byte) main::l#1 [phi:main::@4->main::@4#0] -- register_copy //SEG35 main::@4 @@ -853,20 +854,21 @@ main: { //SEG36 asm { eor#$55 tax } eor #$55 tax - //SEG37 [15] *((const byte*) SCREEN#0 + (byte) main::k#4) ← (byte) main::l#2 [ main::k#4 main::l#2 ] ( main:2 [ main::k#4 main::l#2 ] ) -- pbuc1_derefidx_vbuyy=vbuz1 - lda l - sta SCREEN,y - //SEG38 [16] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuz1=_inc_vbuz1 - inc l - //SEG39 [17] if((byte) main::l#1!=(byte/signed byte/word/signed word) 101) goto main::@4 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuz1_neq_vbuc1_then_la1 - lda l - cmp #$65 + //SEG37 [15] *((const byte*) SCREEN#0 + (byte) main::k#4) ← (byte) main::l#2 [ main::k#4 main::l#2 ] ( main:2 [ main::k#4 main::l#2 ] ) -- pbuc1_derefidx_vbuz1=vbuyy + tya + ldx k + sta SCREEN,x + //SEG38 [16] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuyy=_inc_vbuyy + iny + //SEG39 [17] if((byte) main::l#1!=(byte/signed byte/word/signed word) 101) goto main::@4 [ main::k#4 main::l#1 ] ( main:2 [ main::k#4 main::l#1 ] ) -- vbuyy_neq_vbuc1_then_la1 + cpy #$65 bne b4 //SEG40 main::@7 - //SEG41 [18] (byte) main::k#1 ← ++ (byte) main::k#4 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuyy=_inc_vbuyy - iny - //SEG42 [19] if((byte) main::k#1!=(byte/signed byte/word/signed word) 101) goto main::@3 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuyy_neq_vbuc1_then_la1 - cpy #$65 + //SEG41 [18] (byte) main::k#1 ← ++ (byte) main::k#4 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuz1=_inc_vbuz1 + inc k + //SEG42 [19] if((byte) main::k#1!=(byte/signed byte/word/signed word) 101) goto main::@3 [ main::k#1 ] ( main:2 [ main::k#1 ] ) -- vbuz1_neq_vbuc1_then_la1 + lda k + cmp #$65 bne b3 //SEG43 main::@return //SEG44 [20] return [ ] ( main:2 [ ] ) diff --git a/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.sym b/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.sym index 985c9b8cf..6937f6f68 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.sym +++ b/src/test/java/dk/camelot64/kickc/test/ref/asm-clobber.sym @@ -18,13 +18,13 @@ (byte) main::j#1 reg byte a 151.5 (byte) main::j#2 reg byte a 151.5 (byte) main::k -(byte) main::k#1 reg byte y 16.5 -(byte) main::k#4 reg byte y 20.499999999999996 +(byte) main::k#1 k zp ZP_BYTE:2 16.5 +(byte) main::k#4 k zp ZP_BYTE:2 20.499999999999996 (byte) main::l -(byte) main::l#1 l zp ZP_BYTE:2 151.5 -(byte) main::l#2 l zp ZP_BYTE:2 101.0 +(byte) main::l#1 reg byte y 151.5 +(byte) main::l#2 reg byte y 101.0 reg byte x [ main::i#4 main::i#1 ] reg byte a [ main::j#2 main::j#1 ] -reg byte y [ main::k#4 main::k#1 ] -zp ZP_BYTE:2 [ main::l#2 main::l#1 ] +zp ZP_BYTE:2 [ main::k#4 main::k#1 ] +reg byte y [ main::l#2 main::l#1 ] diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm index b1630cb08..4bc62212c 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm @@ -193,9 +193,9 @@ line_ydxi: { ldy y jsr plot inc y - lda e + lda xd clc - adc xd + adc e sta e lda yd cmp e @@ -253,9 +253,9 @@ line_xdyi: { ldy y jsr plot inx - lda e + lda yd clc - adc yd + adc e sta e lda xd cmp e @@ -287,9 +287,9 @@ line_ydxd: { ldy y jsr plot inc y - lda e + lda xd clc - adc xd + adc e sta e lda yd cmp e @@ -321,9 +321,9 @@ line_xdyd: { ldy y jsr plot inx - lda e + lda yd clc - adc yd + adc e sta e lda xd cmp e @@ -403,8 +403,8 @@ init_screen: { lda #>BITMAP sta b+1 b1: - ldy #0 - tya + lda #0 + tay sta (b),y inc b bne !+ @@ -421,8 +421,8 @@ init_screen: { lda #>SCREEN sta c+1 b2: - ldy #0 lda #$14 + ldy #0 sta (c),y inc c bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log index fbee1ec7f..ca97b843c 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log @@ -4781,9 +4781,9 @@ line_ydxi: { //SEG183 [93] (byte) line_ydxi::y#2 ← (byte) line_ydxi::y#3 + (byte/signed byte/word/signed word) 1 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] ) -- vbuz1=vbuz1_plus_1 inc y //SEG184 [94] (byte) line_ydxi::e#1 ← (byte) line_ydxi::e#3 + (byte) line_ydxi::xd#2 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda xd clc - adc xd + adc e sta e //SEG185 [95] if((byte) line_ydxi::yd#5>=(byte) line_ydxi::e#1) goto line_ydxi::@2 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda yd @@ -4863,8 +4863,8 @@ plot: { ora plot_bit,x sta _1 //SEG203 [108] *((byte*) plot::plotter#0) ← (byte~) plot::$1 [ ] ( main:2::lines:12::line:21::line_ydxi:42::plot:92 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#3 line_ydxi::e#3 ] main:2::lines:12::line:21::line_ydxi:86::plot:92 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#3 line_ydxi::e#3 ] main:2::lines:12::line:21::line_xdyi:35::plot:115 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::x#3 line_xdyi::y#3 line_xdyi::e#3 ] main:2::lines:12::line:21::line_xdyi:80::plot:115 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::x#3 line_xdyi::y#3 line_xdyi::e#3 ] main:2::lines:12::line:21::line_ydxd:56::plot:130 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#3 line_ydxd::e#3 ] main:2::lines:12::line:21::line_ydxd:72::plot:130 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#3 line_ydxd::e#3 ] main:2::lines:12::line:21::line_xdyd:50::plot:145 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::x#3 line_xdyd::y#3 line_xdyd::e#3 ] main:2::lines:12::line:21::line_xdyd:66::plot:145 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::x#3 line_xdyd::y#3 line_xdyd::e#3 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda _1 + ldy #0 sta (plotter),y jmp breturn //SEG204 plot::@return @@ -4912,9 +4912,9 @@ line_xdyi: { //SEG220 [116] (byte) line_xdyi::x#2 ← (byte) line_xdyi::x#3 + (byte/signed byte/word/signed word) 1 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] ) -- vbuz1=vbuz1_plus_1 inc x //SEG221 [117] (byte) line_xdyi::e#1 ← (byte) line_xdyi::e#3 + (byte) line_xdyi::yd#2 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda yd clc - adc yd + adc e sta e //SEG222 [118] if((byte) line_xdyi::xd#5>=(byte) line_xdyi::e#1) goto line_xdyi::@2 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda xd @@ -4993,9 +4993,9 @@ line_ydxd: { //SEG248 [131] (byte) line_ydxd::y#2 ← (byte) line_ydxd::y#3 + (byte/signed byte/word/signed word) 1 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] ) -- vbuz1=vbuz1_plus_1 inc y //SEG249 [132] (byte) line_ydxd::e#1 ← (byte) line_ydxd::e#3 + (byte) line_ydxd::xd#2 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda xd clc - adc xd + adc e sta e //SEG250 [133] if((byte) line_ydxd::yd#5>=(byte) line_ydxd::e#1) goto line_ydxd::@2 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda yd @@ -5074,9 +5074,9 @@ line_xdyd: { //SEG276 [146] (byte) line_xdyd::x#2 ← (byte) line_xdyd::x#3 + (byte/signed byte/word/signed word) 1 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] ) -- vbuz1=vbuz1_plus_1 inc x //SEG277 [147] (byte) line_xdyd::e#1 ← (byte) line_xdyd::e#3 + (byte) line_xdyd::yd#2 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda yd clc - adc yd + adc e sta e //SEG278 [148] if((byte) line_xdyd::xd#5>=(byte) line_xdyd::e#1) goto line_xdyd::@2 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda xd @@ -5282,8 +5282,8 @@ init_screen: { //SEG342 init_screen::@1 b1: //SEG343 [183] *((byte*) init_screen::b#2) ← (byte/signed byte/word/signed word) 0 [ init_screen::b#2 ] ( main:2::init_screen:8 [ init_screen::b#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #0 + ldy #0 sta (b),y //SEG344 [184] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:2::init_screen:8 [ init_screen::b#1 ] ) -- pbuz1=_inc_pbuz1 inc b @@ -5312,8 +5312,8 @@ init_screen: { //SEG350 init_screen::@2 b2: //SEG351 [187] *((byte*) init_screen::c#2) ← (byte/signed byte/word/signed word) 20 [ init_screen::c#2 ] ( main:2::init_screen:8 [ init_screen::c#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #$14 + ldy #0 sta (c),y //SEG352 [188] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2 [ init_screen::c#1 ] ( main:2::init_screen:8 [ init_screen::c#1 ] ) -- pbuz1=_inc_pbuz1 inc c @@ -6122,9 +6122,9 @@ line_ydxi: { //SEG183 [93] (byte) line_ydxi::y#2 ← (byte) line_ydxi::y#3 + (byte/signed byte/word/signed word) 1 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] ) -- vbuz1=vbuz1_plus_1 inc y //SEG184 [94] (byte) line_ydxi::e#1 ← (byte) line_ydxi::e#3 + (byte) line_ydxi::xd#2 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda xd clc - adc xd + adc e sta e //SEG185 [95] if((byte) line_ydxi::yd#5>=(byte) line_ydxi::e#1) goto line_ydxi::@2 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda yd @@ -6236,9 +6236,9 @@ line_xdyi: { //SEG220 [116] (byte) line_xdyi::x#2 ← (byte) line_xdyi::x#3 + (byte/signed byte/word/signed word) 1 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] ) -- vbuxx=vbuxx_plus_1 inx //SEG221 [117] (byte) line_xdyi::e#1 ← (byte) line_xdyi::e#3 + (byte) line_xdyi::yd#2 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda yd clc - adc yd + adc e sta e //SEG222 [118] if((byte) line_xdyi::xd#5>=(byte) line_xdyi::e#1) goto line_xdyi::@2 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda xd @@ -6312,9 +6312,9 @@ line_ydxd: { //SEG248 [131] (byte) line_ydxd::y#2 ← (byte) line_ydxd::y#3 + (byte/signed byte/word/signed word) 1 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] ) -- vbuz1=vbuz1_plus_1 inc y //SEG249 [132] (byte) line_ydxd::e#1 ← (byte) line_ydxd::e#3 + (byte) line_ydxd::xd#2 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda xd clc - adc xd + adc e sta e //SEG250 [133] if((byte) line_ydxd::yd#5>=(byte) line_ydxd::e#1) goto line_ydxd::@2 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda yd @@ -6388,9 +6388,9 @@ line_xdyd: { //SEG276 [146] (byte) line_xdyd::x#2 ← (byte) line_xdyd::x#3 + (byte/signed byte/word/signed word) 1 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] ) -- vbuxx=vbuxx_plus_1 inx //SEG277 [147] (byte) line_xdyd::e#1 ← (byte) line_xdyd::e#3 + (byte) line_xdyd::yd#2 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda yd clc - adc yd + adc e sta e //SEG278 [148] if((byte) line_xdyd::xd#5>=(byte) line_xdyd::e#1) goto line_xdyd::@2 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda xd @@ -6570,8 +6570,8 @@ init_screen: { //SEG342 init_screen::@1 b1: //SEG343 [183] *((byte*) init_screen::b#2) ← (byte/signed byte/word/signed word) 0 [ init_screen::b#2 ] ( main:2::init_screen:8 [ init_screen::b#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #0 + ldy #0 sta (b),y //SEG344 [184] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:2::init_screen:8 [ init_screen::b#1 ] ) -- pbuz1=_inc_pbuz1 inc b @@ -6600,8 +6600,8 @@ init_screen: { //SEG350 init_screen::@2 b2: //SEG351 [187] *((byte*) init_screen::c#2) ← (byte/signed byte/word/signed word) 20 [ init_screen::c#2 ] ( main:2::init_screen:8 [ init_screen::c#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #$14 + ldy #0 sta (c),y //SEG352 [188] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2 [ init_screen::c#1 ] ( main:2::init_screen:8 [ init_screen::c#1 ] ) -- pbuz1=_inc_pbuz1 inc c @@ -6690,7 +6690,7 @@ Removing instruction lda yd Removing instruction ldy #0 Removing instruction lda #>0 Replacing instruction ldx #0 with TAX -Replacing instruction lda #0 with TYA +Replacing instruction ldy #0 with TAY Succesful ASM optimization Pass5UnnecesaryLoadElimination Replacing label b1_from_b5 with b1 Replacing label b1_from_b3 with b1 @@ -7519,9 +7519,9 @@ line_ydxi: { //SEG183 [93] (byte) line_ydxi::y#2 ← (byte) line_ydxi::y#3 + (byte/signed byte/word/signed word) 1 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::e#3 line_ydxi::y#2 ] ) -- vbuz1=vbuz1_plus_1 inc y //SEG184 [94] (byte) line_ydxi::e#1 ← (byte) line_ydxi::e#3 + (byte) line_ydxi::xd#2 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda xd clc - adc xd + adc e sta e //SEG185 [95] if((byte) line_ydxi::yd#5>=(byte) line_ydxi::e#1) goto line_ydxi::@2 [ line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ( main:2::lines:12::line:21::line_ydxi:42 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] main:2::lines:12::line:21::line_ydxi:86 [ lines::l#2 line_ydxi::xd#2 line_ydxi::yd#5 line_ydxi::y1#6 line_ydxi::x#3 line_ydxi::y#2 line_ydxi::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda yd @@ -7617,9 +7617,9 @@ line_xdyi: { //SEG220 [116] (byte) line_xdyi::x#2 ← (byte) line_xdyi::x#3 + (byte/signed byte/word/signed word) 1 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::e#3 line_xdyi::x#2 ] ) -- vbuxx=vbuxx_plus_1 inx //SEG221 [117] (byte) line_xdyi::e#1 ← (byte) line_xdyi::e#3 + (byte) line_xdyi::yd#2 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda yd clc - adc yd + adc e sta e //SEG222 [118] if((byte) line_xdyi::xd#5>=(byte) line_xdyi::e#1) goto line_xdyi::@2 [ line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ( main:2::lines:12::line:21::line_xdyi:35 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] main:2::lines:12::line:21::line_xdyi:80 [ lines::l#2 line_xdyi::yd#2 line_xdyi::xd#5 line_xdyi::x1#6 line_xdyi::y#3 line_xdyi::x#2 line_xdyi::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda xd @@ -7680,9 +7680,9 @@ line_ydxd: { //SEG248 [131] (byte) line_ydxd::y#2 ← (byte) line_ydxd::y#3 + (byte/signed byte/word/signed word) 1 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::e#3 line_ydxd::y#2 ] ) -- vbuz1=vbuz1_plus_1 inc y //SEG249 [132] (byte) line_ydxd::e#1 ← (byte) line_ydxd::e#3 + (byte) line_ydxd::xd#2 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda xd clc - adc xd + adc e sta e //SEG250 [133] if((byte) line_ydxd::yd#5>=(byte) line_ydxd::e#1) goto line_ydxd::@2 [ line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ( main:2::lines:12::line:21::line_ydxd:56 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] main:2::lines:12::line:21::line_ydxd:72 [ lines::l#2 line_ydxd::xd#2 line_ydxd::yd#5 line_ydxd::y1#6 line_ydxd::x#3 line_ydxd::y#2 line_ydxd::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda yd @@ -7743,9 +7743,9 @@ line_xdyd: { //SEG276 [146] (byte) line_xdyd::x#2 ← (byte) line_xdyd::x#3 + (byte/signed byte/word/signed word) 1 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::e#3 line_xdyd::x#2 ] ) -- vbuxx=vbuxx_plus_1 inx //SEG277 [147] (byte) line_xdyd::e#1 ← (byte) line_xdyd::e#3 + (byte) line_xdyd::yd#2 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda e + lda yd clc - adc yd + adc e sta e //SEG278 [148] if((byte) line_xdyd::xd#5>=(byte) line_xdyd::e#1) goto line_xdyd::@2 [ line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ( main:2::lines:12::line:21::line_xdyd:50 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] main:2::lines:12::line:21::line_xdyd:66 [ lines::l#2 line_xdyd::yd#2 line_xdyd::xd#5 line_xdyd::x1#6 line_xdyd::y#3 line_xdyd::x#2 line_xdyd::e#1 ] ) -- vbuz1_ge_vbuz2_then_la1 lda xd @@ -7891,8 +7891,8 @@ init_screen: { //SEG342 init_screen::@1 b1: //SEG343 [183] *((byte*) init_screen::b#2) ← (byte/signed byte/word/signed word) 0 [ init_screen::b#2 ] ( main:2::init_screen:8 [ init_screen::b#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 - tya + lda #0 + tay sta (b),y //SEG344 [184] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:2::init_screen:8 [ init_screen::b#1 ] ) -- pbuz1=_inc_pbuz1 inc b @@ -7917,8 +7917,8 @@ init_screen: { //SEG350 init_screen::@2 b2: //SEG351 [187] *((byte*) init_screen::c#2) ← (byte/signed byte/word/signed word) 20 [ init_screen::c#2 ] ( main:2::init_screen:8 [ init_screen::c#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #$14 + ldy #0 sta (c),y //SEG352 [188] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2 [ init_screen::c#1 ] ( main:2::init_screen:8 [ init_screen::c#1 ] ) -- pbuz1=_inc_pbuz1 inc c diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm index 120e78981..926bd4d2f 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm @@ -138,8 +138,8 @@ init_screen: { lda #>BITMAP sta b+1 b1: - ldy #0 - tya + lda #0 + tay sta (b),y inc b bne !+ @@ -156,8 +156,8 @@ init_screen: { lda #>SCREEN sta c+1 b2: - ldy #0 lda #$14 + ldy #0 sta (c),y inc c bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log index a76f57dad..4853b11c6 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log @@ -1904,10 +1904,10 @@ plot: { lda plot_yhi,x sta _8 //SEG50 [30] (word) plot::plotter_y#1 ← (byte/signed byte/word/signed word) 0 hi= (byte~) plot::$8 [ plot::x#0 plot::y#0 plot::plotter_x#2 plot::plotter_y#1 ] ( main:2::plots:13::plot:21 [ plots::i#2 plot::x#0 plot::y#0 plot::plotter_x#2 plot::plotter_y#1 ] ) -- vwuz1=vbuc1_sethi_vbuz2 - lda #0 - sta plotter_y lda _8 sta plotter_y+1 + lda #<0 + sta plotter_y //SEG51 [31] (byte~) plot::$9 ← *((const byte[256]) plot_ylo#0 + (byte) plot::y#0) [ plot::x#0 plot::plotter_x#2 plot::plotter_y#1 plot::$9 ] ( main:2::plots:13::plot:21 [ plots::i#2 plot::x#0 plot::plotter_x#2 plot::plotter_y#1 plot::$9 ] ) -- vbuz1=pbuc1_derefidx_vbuz2 ldx y lda plot_ylo,x @@ -1932,8 +1932,8 @@ plot: { ora plot_bit,x sta _5 //SEG55 [35] *((byte*) plot::plotter#0) ← (byte~) plot::$5 [ ] ( main:2::plots:13::plot:21 [ plots::i#2 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda _5 + ldy #0 sta (plotter),y jmp breturn //SEG56 plot::@return @@ -2108,8 +2108,8 @@ init_screen: { //SEG110 init_screen::@1 b1: //SEG111 [65] *((byte*) init_screen::b#2) ← (byte/signed byte/word/signed word) 0 [ init_screen::b#2 ] ( main:2::init_screen:8 [ init_screen::b#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #0 + ldy #0 sta (b),y //SEG112 [66] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:2::init_screen:8 [ init_screen::b#1 ] ) -- pbuz1=_inc_pbuz1 inc b @@ -2138,8 +2138,8 @@ init_screen: { //SEG118 init_screen::@2 b2: //SEG119 [69] *((byte*) init_screen::c#2) ← (byte/signed byte/word/signed word) 20 [ init_screen::c#2 ] ( main:2::init_screen:8 [ init_screen::c#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #$14 + ldy #0 sta (c),y //SEG120 [70] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2 [ init_screen::c#1 ] ( main:2::init_screen:8 [ init_screen::c#1 ] ) -- pbuz1=_inc_pbuz1 inc c @@ -2590,8 +2590,8 @@ init_screen: { //SEG110 init_screen::@1 b1: //SEG111 [65] *((byte*) init_screen::b#2) ← (byte/signed byte/word/signed word) 0 [ init_screen::b#2 ] ( main:2::init_screen:8 [ init_screen::b#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #0 + ldy #0 sta (b),y //SEG112 [66] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:2::init_screen:8 [ init_screen::b#1 ] ) -- pbuz1=_inc_pbuz1 inc b @@ -2620,8 +2620,8 @@ init_screen: { //SEG118 init_screen::@2 b2: //SEG119 [69] *((byte*) init_screen::c#2) ← (byte/signed byte/word/signed word) 20 [ init_screen::c#2 ] ( main:2::init_screen:8 [ init_screen::c#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #$14 + ldy #0 sta (c),y //SEG120 [70] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2 [ init_screen::c#1 ] ( main:2::init_screen:8 [ init_screen::c#1 ] ) -- pbuz1=_inc_pbuz1 inc c @@ -2677,7 +2677,7 @@ Removing instruction ldx i Removing instruction ldy #0 Removing instruction lda #>0 Replacing instruction ldx #0 with TAX -Replacing instruction lda #0 with TYA +Replacing instruction ldy #0 with TAY Succesful ASM optimization Pass5UnnecesaryLoadElimination Replacing label b1_from_b3 with b1 Replacing label b10_from_b1 with b10 @@ -3125,8 +3125,8 @@ init_screen: { //SEG110 init_screen::@1 b1: //SEG111 [65] *((byte*) init_screen::b#2) ← (byte/signed byte/word/signed word) 0 [ init_screen::b#2 ] ( main:2::init_screen:8 [ init_screen::b#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 - tya + lda #0 + tay sta (b),y //SEG112 [66] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:2::init_screen:8 [ init_screen::b#1 ] ) -- pbuz1=_inc_pbuz1 inc b @@ -3151,8 +3151,8 @@ init_screen: { //SEG118 init_screen::@2 b2: //SEG119 [69] *((byte*) init_screen::c#2) ← (byte/signed byte/word/signed word) 20 [ init_screen::c#2 ] ( main:2::init_screen:8 [ init_screen::c#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #$14 + ldy #0 sta (c),y //SEG120 [70] (byte*) init_screen::c#1 ← ++ (byte*) init_screen::c#2 [ init_screen::c#1 ] ( main:2::init_screen:8 [ init_screen::c#1 ] ) -- pbuz1=_inc_pbuz1 inc c diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bresenham.asm b/src/test/java/dk/camelot64/kickc/test/ref/bresenham.asm index 4ad715264..13a9c3add 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bresenham.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/bresenham.asm @@ -21,8 +21,8 @@ main: { lda #>SCREEN+4*$28+4 sta cursor+1 b1: - ldy #0 lda #STAR + ldy #0 sta (cursor),y inc x inc cursor diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bresenham.log b/src/test/java/dk/camelot64/kickc/test/ref/bresenham.log index 047820816..e819cddda 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bresenham.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bresenham.log @@ -640,8 +640,8 @@ main: { //SEG20 main::@1 b1: //SEG21 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #STAR + ldy #0 sta (cursor),y //SEG22 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ) -- vbuz1=vbuz1_plus_1 inc x @@ -788,8 +788,8 @@ main: { //SEG20 main::@1 b1: //SEG21 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #STAR + ldy #0 sta (cursor),y //SEG22 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ) -- vbuz1=vbuz1_plus_1 inc x @@ -968,8 +968,8 @@ main: { //SEG20 main::@1 b1: //SEG21 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #STAR + ldy #0 sta (cursor),y //SEG22 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ) -- vbuz1=vbuz1_plus_1 inc x diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm b/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm index a10d8ff30..a7a92890b 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm @@ -46,9 +46,9 @@ main: { clc adc #<$28 sta idx - bcc !+ - inc idx+1 - !: + lda idx+1 + adc #>$28 + sta idx+1 tya sec sbc #xd diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.log b/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.log index 07782b060..70f6d919a 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bresenhamarr.log @@ -659,9 +659,9 @@ main: { clc adc #<$28 sta idx - bcc !+ - inc idx+1 - !: + lda idx+1 + adc #>$28 + sta idx+1 //SEG29 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) -- vbuz1=vbuz1_minus_vbuc1 lda e sec @@ -708,10 +708,10 @@ REGISTER UPLIFT SCOPES Uplift Scope [main] 55: zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] 46.75: zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#2 ] 29.33: zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] 14.67: zp ZP_BYTE:4 [ main::x#2 main::x#1 ] Uplift Scope [] -Uplifting [main] best 1238 combination reg byte y [ main::e#3 main::e#5 main::e#1 main::e#2 ] zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#2 ] zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] reg byte x [ main::x#2 main::x#1 ] -Uplifting [] best 1238 combination +Uplifting [main] best 1243 combination reg byte y [ main::e#3 main::e#5 main::e#1 main::e#2 ] zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#2 ] zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] reg byte x [ main::x#2 main::x#1 ] +Uplifting [] best 1243 combination Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] -Uplifting [main] best 1238 combination zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] +Uplifting [main] best 1243 combination zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] Allocated (was zp ZP_BYTE:6) zp ZP_BYTE:4 [ main::y#2 main::y#4 main::y#1 ] ASSEMBLER BEFORE OPTIMIZATION @@ -806,9 +806,9 @@ main: { clc adc #<$28 sta idx - bcc !+ - inc idx+1 - !: + lda idx+1 + adc #>$28 + sta idx+1 //SEG29 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) -- vbuyy=vbuyy_minus_vbuc1 tya sec @@ -910,7 +910,7 @@ zp ZP_BYTE:4 [ main::y#2 main::y#4 main::y#1 ] FINAL ASSEMBLER -Score: 1082 +Score: 1087 //SEG0 Basic Upstart .pc = $801 "Basic" @@ -989,9 +989,9 @@ main: { clc adc #<$28 sta idx - bcc !+ - inc idx+1 - !: + lda idx+1 + adc #>$28 + sta idx+1 //SEG29 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) -- vbuyy=vbuyy_minus_vbuc1 tya sec diff --git a/src/test/java/dk/camelot64/kickc/test/ref/callconstparam.log b/src/test/java/dk/camelot64/kickc/test/ref/callconstparam.log index a1ff40bd5..984f6de78 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/callconstparam.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/callconstparam.log @@ -462,8 +462,8 @@ line: { //SEG28 line::@1 b1: //SEG29 [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda x + ldy #0 sta (screen),y //SEG30 [12] (byte*) screen#11 ← ++ (byte*) screen#10 [ line::x1#3 screen#11 line::x#2 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#2 ] main:2::line:7 [ line::x1#3 screen#11 line::x#2 ] ) -- pbuz1=_inc_pbuz1 inc screen diff --git a/src/test/java/dk/camelot64/kickc/test/ref/chargen.log b/src/test/java/dk/camelot64/kickc/test/ref/chargen.log index 6538bb855..c1ddfa9e0 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/chargen.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/chargen.log @@ -711,8 +711,8 @@ main: { //SEG36 main::@3 b3: //SEG37 [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda c + ldy #0 sta (sc),y //SEG38 [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ( main:2 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/constants.asm b/src/test/java/dk/camelot64/kickc/test/ref/constants.asm index ae24cb9e2..e48b40bbd 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/constants.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/constants.asm @@ -237,8 +237,8 @@ print_cls: { lda #>$400 sta sc+1 b1: - ldy #0 lda #' ' + ldy #0 sta (sc),y inc sc bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/constants.log b/src/test/java/dk/camelot64/kickc/test/ref/constants.log index 76cba19ee..58049bbb8 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/constants.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/constants.log @@ -2897,8 +2897,8 @@ print_cls: { //SEG178 print_cls::@1 b1: //SEG179 [70] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG180 [71] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -3519,8 +3519,8 @@ print_cls: { //SEG178 print_cls::@1 b1: //SEG179 [70] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG180 [71] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -4202,8 +4202,8 @@ print_cls: { //SEG178 print_cls::@1 b1: //SEG179 [70] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG180 [71] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/halfscii.log b/src/test/java/dk/camelot64/kickc/test/ref/halfscii.log index 7bfe2d78f..ea4793119 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/halfscii.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/halfscii.log @@ -1602,8 +1602,8 @@ main: { asl sta bits_gen_7 //SEG73 [48] *((byte*) main::charset4#10) ← (byte) main::bits_gen#7 [ main::chargen#10 main::charset4#10 ] ( main:2 [ main::chargen#10 main::charset4#10 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda bits_gen_7 + ldy #0 sta (charset4),y //SEG74 [49] (byte*) main::charset4#1 ← ++ (byte*) main::charset4#10 [ main::chargen#10 main::charset4#1 ] ( main:2 [ main::chargen#10 main::charset4#1 ] ) -- pbuz1=_inc_pbuz1 inc charset4 diff --git a/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.asm b/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.asm index b7a717179..1fab21b3b 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.asm @@ -85,8 +85,8 @@ print_cls: { lda #>$400 sta sc+1 b1: - ldy #0 lda #' ' + ldy #0 sta (sc),y inc sc bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.log b/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.log index 86ab80c42..7f4c45d65 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/incrementinarray.log @@ -1177,8 +1177,8 @@ print_cls: { //SEG63 print_cls::@1 b1: //SEG64 [29] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG65 [30] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -1431,8 +1431,8 @@ print_cls: { //SEG63 print_cls::@1 b1: //SEG64 [29] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG65 [30] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -1705,8 +1705,8 @@ print_cls: { //SEG63 print_cls::@1 b1: //SEG64 [29] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG65 [30] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/inline-word.asm b/src/test/java/dk/camelot64/kickc/test/ref/inline-word.asm index 015fb68fd..311a0f916 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/inline-word.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/inline-word.asm @@ -16,8 +16,8 @@ main: { lda his,y sta w+1 stx w - ldy #0 lda #'*' + ldy #0 sta (sc),y inx cpx #8 diff --git a/src/test/java/dk/camelot64/kickc/test/ref/inline-word.log b/src/test/java/dk/camelot64/kickc/test/ref/inline-word.log index ac90b7700..4ade5f7d3 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/inline-word.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/inline-word.log @@ -420,8 +420,8 @@ main: { lda w+1 sta sc+1 //SEG22 [9] *((byte*) main::sc#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #'*' + ldy #0 sta (sc),y //SEG23 [10] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuz1=_inc_vbuz1 inc l @@ -540,8 +540,8 @@ main: { stx w //SEG21 [8] (byte*) main::sc#0 ← ((byte*)) (word) main::w#0 [ main::h#4 main::l#2 main::sc#0 ] ( main:2 [ main::h#4 main::l#2 main::sc#0 ] ) -- pbuz1=_ptrby_vwuz1 //SEG22 [9] *((byte*) main::sc#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #'*' + ldy #0 sta (sc),y //SEG23 [10] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuxx=_inc_vbuxx inx @@ -666,8 +666,8 @@ main: { stx w //SEG21 [8] (byte*) main::sc#0 ← ((byte*)) (word) main::w#0 [ main::h#4 main::l#2 main::sc#0 ] ( main:2 [ main::h#4 main::l#2 main::sc#0 ] ) -- pbuz1=_ptrby_vwuz1 //SEG22 [9] *((byte*) main::sc#0) ← (byte) '*' [ main::h#4 main::l#2 ] ( main:2 [ main::h#4 main::l#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #'*' + ldy #0 sta (sc),y //SEG23 [10] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::h#4 main::l#1 ] ( main:2 [ main::h#4 main::l#1 ] ) -- vbuxx=_inc_vbuxx inx diff --git a/src/test/java/dk/camelot64/kickc/test/ref/loopmin.log b/src/test/java/dk/camelot64/kickc/test/ref/loopmin.log index 112038a7e..09a8333f9 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/loopmin.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/loopmin.log @@ -325,9 +325,9 @@ main: { //SEG18 main::@3 b3: //SEG19 [7] (byte) main::s#1 ← (byte) main::s#2 + (byte) main::i#2 [ main::i#2 main::s#1 ] ( main:2 [ main::i#2 main::s#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda s + lda i clc - adc i + adc s sta s //SEG20 [8] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2] b2_from_b1: diff --git a/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.asm b/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.asm index 7a6540897..6564649db 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.asm @@ -22,8 +22,8 @@ lvaluevar: { bcc b2 rts b2: - ldy #0 lda #b + ldy #0 sta (screen),y inc screen bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.log b/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.log index 6d0774e8c..7c2a07742 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/ptrtest.log @@ -929,8 +929,8 @@ lvaluevar: { //SEG33 lvaluevar::@2 b2: //SEG34 [17] *((byte*) lvaluevar::screen#2) ← (const byte) lvaluevar::b#0 [ lvaluevar::i#2 lvaluevar::screen#2 ] ( main:2::lvaluevar:11 [ lvaluevar::i#2 lvaluevar::screen#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #b + ldy #0 sta (screen),y //SEG35 [18] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::i#2 lvaluevar::screen#1 ] ( main:2::lvaluevar:11 [ lvaluevar::i#2 lvaluevar::screen#1 ] ) -- pbuz1=_inc_pbuz1 inc screen @@ -1178,8 +1178,8 @@ lvaluevar: { //SEG33 lvaluevar::@2 b2: //SEG34 [17] *((byte*) lvaluevar::screen#2) ← (const byte) lvaluevar::b#0 [ lvaluevar::i#2 lvaluevar::screen#2 ] ( main:2::lvaluevar:11 [ lvaluevar::i#2 lvaluevar::screen#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #b + ldy #0 sta (screen),y //SEG35 [18] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::i#2 lvaluevar::screen#1 ] ( main:2::lvaluevar:11 [ lvaluevar::i#2 lvaluevar::screen#1 ] ) -- pbuz1=_inc_pbuz1 inc screen @@ -1462,8 +1462,8 @@ lvaluevar: { //SEG33 lvaluevar::@2 b2: //SEG34 [17] *((byte*) lvaluevar::screen#2) ← (const byte) lvaluevar::b#0 [ lvaluevar::i#2 lvaluevar::screen#2 ] ( main:2::lvaluevar:11 [ lvaluevar::i#2 lvaluevar::screen#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #b + ldy #0 sta (screen),y //SEG35 [18] (byte*) lvaluevar::screen#1 ← ++ (byte*) lvaluevar::screen#2 [ lvaluevar::i#2 lvaluevar::screen#1 ] ( main:2::lvaluevar:11 [ lvaluevar::i#2 lvaluevar::screen#1 ] ) -- pbuz1=_inc_pbuz1 inc screen diff --git a/src/test/java/dk/camelot64/kickc/test/ref/scroll.asm b/src/test/java/dk/camelot64/kickc/test/ref/scroll.asm index c26b982d4..274e83f03 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/scroll.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/scroll.asm @@ -64,8 +64,8 @@ fillscreen: { lda #>SCREEN sta cursor+1 b1: - ldy #0 lda #fill + ldy #0 sta (cursor),y inc cursor bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/scroll.log b/src/test/java/dk/camelot64/kickc/test/ref/scroll.log index f4026d0b5..85f62652c 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/scroll.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/scroll.log @@ -1212,8 +1212,8 @@ fillscreen: { //SEG66 fillscreen::@1 b1: //SEG67 [29] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #fill + ldy #0 sta (cursor),y //SEG68 [30] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- pbuz1=_inc_pbuz1 inc cursor @@ -1445,8 +1445,8 @@ fillscreen: { //SEG66 fillscreen::@1 b1: //SEG67 [29] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #fill + ldy #0 sta (cursor),y //SEG68 [30] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- pbuz1=_inc_pbuz1 inc cursor @@ -1727,8 +1727,8 @@ fillscreen: { //SEG66 fillscreen::@1 b1: //SEG67 [29] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #fill + ldy #0 sta (cursor),y //SEG68 [30] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- pbuz1=_inc_pbuz1 inc cursor diff --git a/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.asm b/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.asm index d7c46785f..088289d8d 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.asm @@ -169,8 +169,8 @@ fillscreen: { lda #>SCREEN sta cursor+1 b1: - ldy #0 lda #fill + ldy #0 sta (cursor),y inc cursor bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.log b/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.log index 339e66c04..a15210076 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/scrollbig.log @@ -2773,12 +2773,12 @@ scroll_bit: { rol sta c+1 //SEG66 [29] (byte*) current_chargen#5 ← (const byte*) CHARGEN#0 + (word~) scroll_bit::$4 [ current_chargen#5 nxt#19 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_chargen#5 nxt#19 ] ) -- pbuz1=pbuc1_plus_vwuz2 - lda #CHARGEN - adc _4+1 + lda _4+1 + adc #>CHARGEN sta current_chargen+1 //SEG67 [30] phi from scroll_bit::@8 to scroll_bit::@1 [phi:scroll_bit::@8->scroll_bit::@1] b1_from_b8: @@ -2857,8 +2857,8 @@ scroll_bit: { //SEG97 scroll_bit::@3 b3: //SEG98 [40] *((byte*) scroll_bit::sc#2) ← (byte) scroll_bit::b#2 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#2 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda b + ldy #0 sta (sc),y //SEG99 [41] (byte*) scroll_bit::sc#1 ← (byte*) scroll_bit::sc#2 + (byte/signed byte/word/signed word) 40 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#1 ] ( main:2::scroll_soft:10::scroll_bit:17 [ current_bit#21 nxt#36 current_chargen#19 scroll_bit::r#2 scroll_bit::sc#1 ] ) -- pbuz1=pbuz1_plus_vbuc1 lda sc @@ -3020,8 +3020,8 @@ fillscreen: { //SEG145 fillscreen::@1 b1: //SEG146 [68] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #fill + ldy #0 sta (cursor),y //SEG147 [69] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- pbuz1=_inc_pbuz1 inc cursor @@ -3535,8 +3535,8 @@ fillscreen: { //SEG145 fillscreen::@1 b1: //SEG146 [68] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #fill + ldy #0 sta (cursor),y //SEG147 [69] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- pbuz1=_inc_pbuz1 inc cursor @@ -4112,8 +4112,8 @@ fillscreen: { //SEG145 fillscreen::@1 b1: //SEG146 [68] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #fill + ldy #0 sta (cursor),y //SEG147 [69] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) -- pbuz1=_inc_pbuz1 inc cursor diff --git a/src/test/java/dk/camelot64/kickc/test/ref/signed-words.asm b/src/test/java/dk/camelot64/kickc/test/ref/signed-words.asm index e2ed7e6f2..2ad2ec93c 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/signed-words.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/signed-words.asm @@ -189,8 +189,8 @@ init: { lda #>SCREEN sta sc+1 b1: - ldy #0 lda #' ' + ldy #0 sta (sc),y inc sc bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/signed-words.log b/src/test/java/dk/camelot64/kickc/test/ref/signed-words.log index 92583baec..999f77464 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/signed-words.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/signed-words.log @@ -1817,8 +1817,8 @@ init: { //SEG87 init::@1 b1: //SEG88 [42] *((byte*) init::sc#2) ← (byte) ' ' [ init::sc#2 ] ( main:2::init:5 [ init::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG89 [43] (byte*) init::sc#1 ← ++ (byte*) init::sc#2 [ init::sc#1 ] ( main:2::init:5 [ init::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -2277,8 +2277,8 @@ init: { //SEG87 init::@1 b1: //SEG88 [42] *((byte*) init::sc#2) ← (byte) ' ' [ init::sc#2 ] ( main:2::init:5 [ init::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG89 [43] (byte*) init::sc#1 ← ++ (byte*) init::sc#2 [ init::sc#1 ] ( main:2::init:5 [ init::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -2776,8 +2776,8 @@ init: { //SEG87 init::@1 b1: //SEG88 [42] *((byte*) init::sc#2) ← (byte) ' ' [ init::sc#2 ] ( main:2::init:5 [ init::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG89 [43] (byte*) init::sc#1 ← ++ (byte*) init::sc#2 [ init::sc#1 ] ( main:2::init:5 [ init::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/sinus-basic.log b/src/test/java/dk/camelot64/kickc/test/ref/sinus-basic.log index 8b8d2d408..67d598234 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/sinus-basic.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/sinus-basic.log @@ -2974,8 +2974,8 @@ print_byte: { print_char: { .label ch = 6 //SEG122 [57] *((byte*) char_cursor#23) ← (byte) print_char::ch#2 [ char_cursor#23 ] ( main:2::print_word:31::print_byte:44::print_char:51 [ main::i#10 line_cursor#13 print_word::w#0 print_byte::b#2 char_cursor#23 ] main:2::print_word:31::print_byte:46::print_char:51 [ main::i#10 line_cursor#13 print_byte::b#2 char_cursor#23 ] main:2::print_word:31::print_byte:44::print_char:54 [ main::i#10 line_cursor#13 print_word::w#0 char_cursor#23 ] main:2::print_word:31::print_byte:46::print_char:54 [ main::i#10 line_cursor#13 char_cursor#23 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda ch + ldy #0 sta (char_cursor),y //SEG123 [58] (byte*) char_cursor#10 ← ++ (byte*) char_cursor#23 [ char_cursor#10 ] ( main:2::print_word:31::print_byte:44::print_char:51 [ main::i#10 line_cursor#13 print_word::w#0 print_byte::b#2 char_cursor#10 ] main:2::print_word:31::print_byte:46::print_char:51 [ main::i#10 line_cursor#13 print_byte::b#2 char_cursor#10 ] main:2::print_word:31::print_byte:44::print_char:54 [ main::i#10 line_cursor#13 print_word::w#0 char_cursor#10 ] main:2::print_word:31::print_byte:46::print_char:54 [ main::i#10 line_cursor#13 char_cursor#10 ] ) -- pbuz1=_inc_pbuz1 inc char_cursor diff --git a/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.asm b/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.asm index 5295f6761..f5d98b474 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.asm @@ -171,8 +171,8 @@ clear_screen: { lda #>SCREEN sta sc+1 b1: - ldy #0 lda #' ' + ldy #0 sta (sc),y inc sc bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.log b/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.log index 6693dd014..037b9ed9d 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/sinus-sprites.log @@ -6630,8 +6630,8 @@ clear_screen: { //SEG148 clear_screen::@1 b1: //SEG149 [69] *((byte*) clear_screen::sc#2) ← (byte) ' ' [ clear_screen::sc#2 ] ( main:2::init:5::clear_screen:46 [ clear_screen::sc#2 ] main:2::init:5::clear_screen:65 [ clear_screen::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG150 [70] (byte*) clear_screen::sc#1 ← ++ (byte*) clear_screen::sc#2 [ clear_screen::sc#1 ] ( main:2::init:5::clear_screen:46 [ clear_screen::sc#1 ] main:2::init:5::clear_screen:65 [ clear_screen::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -7322,12 +7322,12 @@ gen_chargen_sprite: { rol sta _0+1 //SEG374 [184] (byte*) gen_chargen_sprite::chargen#0 ← (const byte*) CHARGEN#0 + (word~) gen_chargen_sprite::$1 [ gen_chargen_sprite::sprite#0 gen_chargen_sprite::chargen#0 ] ( main:2::init:5::gen_sprites:55::gen_chargen_sprite:177 [ gen_sprites::i#2 gen_sprites::spr#2 gen_chargen_sprite::sprite#0 gen_chargen_sprite::chargen#0 ] ) -- pbuz1=pbuc1_plus_vwuz2 - lda #CHARGEN - adc _1+1 + lda _1+1 + adc #>CHARGEN sta chargen+1 //SEG375 asm { sei } sei @@ -8379,8 +8379,8 @@ clear_screen: { //SEG148 clear_screen::@1 b1: //SEG149 [69] *((byte*) clear_screen::sc#2) ← (byte) ' ' [ clear_screen::sc#2 ] ( main:2::init:5::clear_screen:46 [ clear_screen::sc#2 ] main:2::init:5::clear_screen:65 [ clear_screen::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG150 [70] (byte*) clear_screen::sc#1 ← ++ (byte*) clear_screen::sc#2 [ clear_screen::sc#1 ] ( main:2::init:5::clear_screen:46 [ clear_screen::sc#1 ] main:2::init:5::clear_screen:65 [ clear_screen::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -10278,8 +10278,8 @@ clear_screen: { //SEG148 clear_screen::@1 b1: //SEG149 [69] *((byte*) clear_screen::sc#2) ← (byte) ' ' [ clear_screen::sc#2 ] ( main:2::init:5::clear_screen:46 [ clear_screen::sc#2 ] main:2::init:5::clear_screen:65 [ clear_screen::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG150 [70] (byte*) clear_screen::sc#1 ← ++ (byte*) clear_screen::sc#2 [ clear_screen::sc#1 ] ( main:2::init:5::clear_screen:46 [ clear_screen::sc#1 ] main:2::init:5::clear_screen:65 [ clear_screen::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.asm b/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.asm index 2faf36a2a..f2b790a26 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.asm @@ -741,8 +741,8 @@ print_cls: { lda #>$400 sta sc+1 b1: - ldy #0 lda #' ' + ldy #0 sta (sc),y inc sc bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.log b/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.log index 153fb2bf6..f2732b5b7 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/test-multiply.log @@ -6894,8 +6894,8 @@ print_byte: { print_char: { .label ch = $d //SEG208 [101] *((byte*) char_cursor#75) ← (byte) print_char::ch#4 [ char_cursor#75 ] ( main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_char:80 [ signed_multiply_error::ma#0 line_cursor#1 print_sword::w#3 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_char:80 [ line_cursor#1 print_sword::w#3 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:88::print_char:95 [ signed_multiply_error::ma#0 line_cursor#1 print_word::w#5 print_byte::b#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:88::print_char:95 [ line_cursor#1 print_word::w#5 print_byte::b#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:88::print_char:95 [ line_cursor#27 multiply_error::ma#0 print_word::w#5 print_byte::b#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:88::print_char:95 [ line_cursor#27 print_word::w#5 print_byte::b#5 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:88::print_char:95 [ multiply_tables_compare::kc_sqr#2 print_word::w#5 print_byte::b#5 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:88::print_char:95 [ print_word::w#5 print_byte::b#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:90::print_char:95 [ signed_multiply_error::ma#0 line_cursor#1 print_byte::b#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:90::print_char:95 [ line_cursor#1 print_byte::b#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:90::print_char:95 [ line_cursor#27 multiply_error::ma#0 print_byte::b#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:90::print_char:95 [ line_cursor#27 print_byte::b#5 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:90::print_char:95 [ multiply_tables_compare::kc_sqr#2 print_byte::b#5 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:90::print_char:95 [ print_byte::b#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:61::print_byte:111::print_char:95 [ signed_multiply_error::b#0 signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_byte::b#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:65::print_byte:111::print_char:95 [ signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_byte::b#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:182::print_char:95 [ line_cursor#27 multiply_error::b#0 multiply_error::ms#0 multiply_error::ma#0 print_byte::b#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:186::print_char:95 [ line_cursor#27 multiply_error::ms#0 multiply_error::ma#0 print_byte::b#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:88::print_char:98 [ signed_multiply_error::ma#0 line_cursor#1 print_word::w#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:88::print_char:98 [ line_cursor#1 print_word::w#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:88::print_char:98 [ line_cursor#27 multiply_error::ma#0 print_word::w#5 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:88::print_char:98 [ line_cursor#27 print_word::w#5 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:88::print_char:98 [ multiply_tables_compare::kc_sqr#2 print_word::w#5 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:88::print_char:98 [ print_word::w#5 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:90::print_char:98 [ signed_multiply_error::ma#0 line_cursor#1 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:90::print_char:98 [ line_cursor#1 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:90::print_char:98 [ line_cursor#27 multiply_error::ma#0 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:90::print_char:98 [ line_cursor#27 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:90::print_char:98 [ multiply_tables_compare::kc_sqr#2 char_cursor#75 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:90::print_char:98 [ char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:61::print_byte:111::print_char:98 [ signed_multiply_error::b#0 signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:65::print_byte:111::print_char:98 [ signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:182::print_char:98 [ line_cursor#27 multiply_error::b#0 multiply_error::ms#0 multiply_error::ma#0 char_cursor#75 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:186::print_char:98 [ line_cursor#27 multiply_error::ms#0 multiply_error::ma#0 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:61::print_char:107 [ signed_multiply_error::b#0 signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_sbyte::b#3 char_cursor#75 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:65::print_char:107 [ signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_sbyte::b#3 char_cursor#75 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda ch + ldy #0 sta (char_cursor),y //SEG209 [102] (byte*) char_cursor#17 ← ++ (byte*) char_cursor#75 [ char_cursor#17 ] ( main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_char:80 [ signed_multiply_error::ma#0 line_cursor#1 print_sword::w#3 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_char:80 [ line_cursor#1 print_sword::w#3 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:88::print_char:95 [ signed_multiply_error::ma#0 line_cursor#1 print_word::w#5 print_byte::b#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:88::print_char:95 [ line_cursor#1 print_word::w#5 print_byte::b#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:88::print_char:95 [ line_cursor#27 multiply_error::ma#0 print_word::w#5 print_byte::b#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:88::print_char:95 [ line_cursor#27 print_word::w#5 print_byte::b#5 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:88::print_char:95 [ multiply_tables_compare::kc_sqr#2 print_word::w#5 print_byte::b#5 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:88::print_char:95 [ print_word::w#5 print_byte::b#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:90::print_char:95 [ signed_multiply_error::ma#0 line_cursor#1 print_byte::b#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:90::print_char:95 [ line_cursor#1 print_byte::b#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:90::print_char:95 [ line_cursor#27 multiply_error::ma#0 print_byte::b#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:90::print_char:95 [ line_cursor#27 print_byte::b#5 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:90::print_char:95 [ multiply_tables_compare::kc_sqr#2 print_byte::b#5 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:90::print_char:95 [ print_byte::b#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:61::print_byte:111::print_char:95 [ signed_multiply_error::b#0 signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_byte::b#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:65::print_byte:111::print_char:95 [ signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_byte::b#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:182::print_char:95 [ line_cursor#27 multiply_error::b#0 multiply_error::ms#0 multiply_error::ma#0 print_byte::b#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:186::print_char:95 [ line_cursor#27 multiply_error::ms#0 multiply_error::ma#0 print_byte::b#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:88::print_char:98 [ signed_multiply_error::ma#0 line_cursor#1 print_word::w#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:88::print_char:98 [ line_cursor#1 print_word::w#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:88::print_char:98 [ line_cursor#27 multiply_error::ma#0 print_word::w#5 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:88::print_char:98 [ line_cursor#27 print_word::w#5 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:88::print_char:98 [ multiply_tables_compare::kc_sqr#2 print_word::w#5 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:88::print_char:98 [ print_word::w#5 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:69::print_word:84::print_byte:90::print_char:98 [ signed_multiply_error::ma#0 line_cursor#1 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sword:73::print_word:84::print_byte:90::print_char:98 [ line_cursor#1 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:190::print_byte:90::print_char:98 [ line_cursor#27 multiply_error::ma#0 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_word:194::print_byte:90::print_char:98 [ line_cursor#27 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:211::print_byte:90::print_char:98 [ multiply_tables_compare::kc_sqr#2 char_cursor#17 ] main:2::multiply_tables_compare:11::print_word:215::print_byte:90::print_char:98 [ char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:61::print_byte:111::print_char:98 [ signed_multiply_error::b#0 signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:65::print_byte:111::print_char:98 [ signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:182::print_char:98 [ line_cursor#27 multiply_error::b#0 multiply_error::ms#0 multiply_error::ma#0 char_cursor#17 ] main:2::multiply_results_compare:13::multiply_error:169::print_byte:186::print_char:98 [ line_cursor#27 multiply_error::ms#0 multiply_error::ma#0 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:61::print_char:107 [ signed_multiply_error::b#0 signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_sbyte::b#3 char_cursor#17 ] main:2::signed_multiply_results_compare:15::signed_multiply_error:36::print_sbyte:65::print_char:107 [ signed_multiply_error::ms#0 signed_multiply_error::ma#0 line_cursor#1 print_sbyte::b#3 char_cursor#17 ] ) -- pbuz1=_inc_pbuz1 inc char_cursor @@ -7899,15 +7899,15 @@ init_multiply: { lda sqr sta _5 //SEG522 [241] *((byte*) init_multiply::sqr1_lo#2) ← (byte~) init_multiply::$5 [ init_multiply::sqr1_lo#2 init_multiply::sqr1_hi#2 init_multiply::c#1 init_multiply::x_2#2 init_multiply::sqr#3 ] ( main:2::init_multiply:7 [ init_multiply::sqr1_lo#2 init_multiply::sqr1_hi#2 init_multiply::c#1 init_multiply::x_2#2 init_multiply::sqr#3 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda _5 + ldy #0 sta (sqr1_lo),y //SEG523 [242] (byte~) init_multiply::$6 ← > (word) init_multiply::sqr#3 [ init_multiply::sqr1_lo#2 init_multiply::sqr1_hi#2 init_multiply::c#1 init_multiply::x_2#2 init_multiply::sqr#3 init_multiply::$6 ] ( main:2::init_multiply:7 [ init_multiply::sqr1_lo#2 init_multiply::sqr1_hi#2 init_multiply::c#1 init_multiply::x_2#2 init_multiply::sqr#3 init_multiply::$6 ] ) -- vbuz1=_hi_vwuz2 lda sqr+1 sta _6 //SEG524 [243] *((byte*) init_multiply::sqr1_hi#2) ← (byte~) init_multiply::$6 [ init_multiply::sqr1_lo#2 init_multiply::sqr1_hi#2 init_multiply::c#1 init_multiply::x_2#2 init_multiply::sqr#3 ] ( main:2::init_multiply:7 [ init_multiply::sqr1_lo#2 init_multiply::sqr1_hi#2 init_multiply::c#1 init_multiply::x_2#2 init_multiply::sqr#3 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda _6 + ldy #0 sta (sqr1_hi),y //SEG525 [244] (byte*) init_multiply::sqr1_hi#1 ← ++ (byte*) init_multiply::sqr1_hi#2 [ init_multiply::sqr1_lo#2 init_multiply::c#1 init_multiply::sqr1_hi#1 init_multiply::x_2#2 init_multiply::sqr#3 ] ( main:2::init_multiply:7 [ init_multiply::sqr1_lo#2 init_multiply::c#1 init_multiply::sqr1_hi#1 init_multiply::x_2#2 init_multiply::sqr#3 ] ) -- pbuz1=_inc_pbuz1 inc sqr1_hi @@ -7978,9 +7978,9 @@ init_multiply: { inc sqr2_hi+1 !: //SEG543 [252] (byte) init_multiply::x_255#1 ← (byte) init_multiply::x_255#2 + (byte) init_multiply::dir#2 [ init_multiply::sqr2_lo#2 init_multiply::dir#2 init_multiply::x_255#1 init_multiply::sqr2_hi#1 ] ( main:2::init_multiply:7 [ init_multiply::sqr2_lo#2 init_multiply::dir#2 init_multiply::x_255#1 init_multiply::sqr2_hi#1 ] ) -- vbuz1=vbuz1_plus_vbuz2 - lda x_255 + lda dir clc - adc dir + adc x_255 sta x_255 //SEG544 [253] if((byte) init_multiply::x_255#1!=(byte/signed byte/word/signed word) 0) goto init_multiply::@12 [ init_multiply::sqr2_lo#2 init_multiply::dir#2 init_multiply::x_255#1 init_multiply::sqr2_hi#1 ] ( main:2::init_multiply:7 [ init_multiply::sqr2_lo#2 init_multiply::dir#2 init_multiply::x_255#1 init_multiply::sqr2_hi#1 ] ) -- vbuz1_neq_0_then_la1 lda x_255 @@ -8047,8 +8047,8 @@ print_cls: { //SEG564 print_cls::@1 b1: //SEG565 [263] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG566 [264] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -10070,8 +10070,8 @@ print_cls: { //SEG564 print_cls::@1 b1: //SEG565 [263] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG566 [264] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc @@ -12169,8 +12169,8 @@ print_cls: { //SEG564 print_cls::@1 b1: //SEG565 [263] *((byte*) print_cls::sc#2) ← (byte) ' ' [ print_cls::sc#2 ] ( main:2::print_cls:5 [ print_cls::sc#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #' ' + ldy #0 sta (sc),y //SEG566 [264] (byte*) print_cls::sc#1 ← ++ (byte*) print_cls::sc#2 [ print_cls::sc#1 ] ( main:2::print_cls:5 [ print_cls::sc#1 ] ) -- pbuz1=_inc_pbuz1 inc sc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/voronoi.asm b/src/test/java/dk/camelot64/kickc/test/ref/voronoi.asm index c49f7c17b..c8e35473c 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/voronoi.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/voronoi.asm @@ -183,8 +183,8 @@ initscreen: { lda #>SCREEN sta screen+1 b1: - ldy #0 lda #FILL + ldy #0 sta (screen),y inc screen bne !+ diff --git a/src/test/java/dk/camelot64/kickc/test/ref/voronoi.log b/src/test/java/dk/camelot64/kickc/test/ref/voronoi.log index 726f4efd1..62d1692c6 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/voronoi.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/voronoi.log @@ -2463,8 +2463,8 @@ initscreen: { //SEG148 initscreen::@1 b1: //SEG149 [80] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ] ( main:2::initscreen:5 [ initscreen::screen#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #FILL + ldy #0 sta (screen),y //SEG150 [81] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] ( main:2::initscreen:5 [ initscreen::screen#1 ] ) -- pbuz1=_inc_pbuz1 inc screen @@ -3049,8 +3049,8 @@ initscreen: { //SEG148 initscreen::@1 b1: //SEG149 [80] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ] ( main:2::initscreen:5 [ initscreen::screen#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #FILL + ldy #0 sta (screen),y //SEG150 [81] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] ( main:2::initscreen:5 [ initscreen::screen#1 ] ) -- pbuz1=_inc_pbuz1 inc screen @@ -3658,8 +3658,8 @@ initscreen: { //SEG148 initscreen::@1 b1: //SEG149 [80] *((byte*) initscreen::screen#2) ← (const byte) FILL#0 [ initscreen::screen#2 ] ( main:2::initscreen:5 [ initscreen::screen#2 ] ) -- _deref_pbuz1=vbuc1 - ldy #0 lda #FILL + ldy #0 sta (screen),y //SEG150 [81] (byte*) initscreen::screen#1 ← ++ (byte*) initscreen::screen#2 [ initscreen::screen#1 ] ( main:2::initscreen:5 [ initscreen::screen#1 ] ) -- pbuz1=_inc_pbuz1 inc screen diff --git a/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.asm b/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.asm index 0eb825b81..22e72984d 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.asm +++ b/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.asm @@ -32,8 +32,8 @@ main: { } sum2: { .label c = 2 - stx $ff tya + stx $ff clc adc $ff clc @@ -42,8 +42,8 @@ sum2: { } sum: { .label c = 2 - stx $ff tya + stx $ff clc adc $ff clc diff --git a/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.log b/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.log index 698ec1c67..37d883ebb 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/zpparammin.log @@ -917,8 +917,8 @@ main: { sum2: { .label c = 2 //SEG36 [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) -- vbuaa=vbuxx_plus_vbuyy - stx $ff tya + stx $ff clc adc $ff //SEG37 [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) -- vbuaa=vbuaa_plus_vbuz1 @@ -934,8 +934,8 @@ sum2: { sum: { .label c = 2 //SEG41 [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) -- vbuaa=vbuxx_plus_vbuyy - stx $ff tya + stx $ff clc adc $ff //SEG42 [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) -- vbuaa=vbuaa_plus_vbuz1 @@ -1116,8 +1116,8 @@ main: { sum2: { .label c = 2 //SEG36 [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) -- vbuaa=vbuxx_plus_vbuyy - stx $ff tya + stx $ff clc adc $ff //SEG37 [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) -- vbuaa=vbuaa_plus_vbuz1 @@ -1131,8 +1131,8 @@ sum2: { sum: { .label c = 2 //SEG41 [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) -- vbuaa=vbuxx_plus_vbuyy - stx $ff tya + stx $ff clc adc $ff //SEG42 [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) -- vbuaa=vbuaa_plus_vbuz1 diff --git a/src/test/java/dk/camelot64/kickc/test/ref/zpptr.log b/src/test/java/dk/camelot64/kickc/test/ref/zpptr.log index 387048fc2..104f06aba 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/zpptr.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/zpptr.log @@ -518,8 +518,8 @@ main: { adc zpptr2+1 sta w+1 //SEG28 [11] *((byte*) main::zpptr2#1) ← (byte) main::k#2 [ main::j#6 main::i#4 main::k#2 ] ( main:2 [ main::j#6 main::i#4 main::k#2 ] ) -- _deref_pbuz1=vbuz2 - ldy #0 lda k + ldy #0 sta (zpptr2_1),y //SEG29 [12] (byte) main::k#1 ← ++ (byte) main::k#2 [ main::j#6 main::i#4 main::k#1 ] ( main:2 [ main::j#6 main::i#4 main::k#1 ] ) -- vbuz1=_inc_vbuz1 inc k