diff --git a/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm b/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm index a704a0e79..ee4169530 100644 --- a/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm +++ b/src/main/fragment/vduz1=vwuz2_dword_vbuc1.asm @@ -1,8 +1,8 @@ -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 lda {z2} sta {z1}+2 lda {z2}+1 sta {z1}+3 +lda #{c1} +sta {z1} +lda #0 +sta {z1}+1 diff --git a/src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm b/src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm new file mode 100644 index 000000000..a704a0e79 --- /dev/null +++ b/src/main/fragment/vduz1=vwuz2_dword_vwuc1.asm @@ -0,0 +1,8 @@ +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +lda {z2} +sta {z1}+2 +lda {z2}+1 +sta {z1}+3 diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 252e07f27..5c86cc61e 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -233,7 +233,7 @@ public class Compiler { List optimizations = new ArrayList<>(); optimizations.add(new PassNAddNumberTypeConversions(program)); optimizations.add(new PassNAddArrayNumberTypeConversions(program)); - optimizations.add(new PassNDowngradeBytePlusWord(program)); + optimizations.add(new PassNDowngradeConstantTypeConversions(program)); optimizations.add(new PassNTypeInference(program)); optimizations.add(new PassNTypeIdSimplification(program)); optimizations.add(new Pass2SizeOfSimplification(program)); diff --git a/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeBytePlusWord.java b/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeConstantTypeConversions.java similarity index 96% rename from src/main/java/dk/camelot64/kickc/passes/PassNDowngradeBytePlusWord.java rename to src/main/java/dk/camelot64/kickc/passes/PassNDowngradeConstantTypeConversions.java index b3f819d53..85a6db2cb 100644 --- a/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeBytePlusWord.java +++ b/src/main/java/dk/camelot64/kickc/passes/PassNDowngradeConstantTypeConversions.java @@ -13,9 +13,9 @@ import java.util.concurrent.atomic.AtomicBoolean; /** * Downgrade any number expression cast that are part of a WORD+NUMBER expression to BYTE if the number is small enough to fit in the byte. */ -public class PassNDowngradeBytePlusWord extends Pass2SsaOptimization { +public class PassNDowngradeConstantTypeConversions extends Pass2SsaOptimization { - public PassNDowngradeBytePlusWord(Program program) { + public PassNDowngradeConstantTypeConversions(Program program) { super(program); } diff --git a/src/test/ref/linegen.asm b/src/test/ref/linegen.asm index 4cbd79681..4b4fcd8a9 100644 --- a/src/test/ref/linegen.asm +++ b/src/test/ref/linegen.asm @@ -335,14 +335,13 @@ lin16u_gen: { sta step lda stepf+1 sta step+1 - lda #<0 - sta val - sta val+1 lda min sta val+2 lda min+1 sta val+3 lda #0 + sta val + sta val+1 sta i sta i+1 b1: