From cd6200481201df0af6ed3ad5bba868d99b0f3f91 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 8 Dec 2019 15:21:23 +0100 Subject: [PATCH] Fixed test data with ASM optimization. --- .../ref/complex/clearscreen/clearscreen.asm | 8 +++---- .../ref/complex/clearscreen/clearscreen.log | 24 +++++++++---------- src/test/ref/loop-break-nested.asm | 5 ++-- src/test/ref/loop-break-nested.log | 17 ++++++------- src/test/ref/textbox.asm | 4 ++-- src/test/ref/textbox.log | 12 +++++----- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/test/ref/complex/clearscreen/clearscreen.asm b/src/test/ref/complex/clearscreen/clearscreen.asm index ac792703d..0d4de4506 100644 --- a/src/test/ref/complex/clearscreen/clearscreen.asm +++ b/src/test/ref/complex/clearscreen/clearscreen.asm @@ -501,8 +501,8 @@ getCharToProcess: { __b1: ldy #0 __b2: - lda (screen_line),y - cmp #' ' + lda #' ' + cmp (screen_line),y bne !__b11+ jmp __b11 !__b11: @@ -1027,9 +1027,9 @@ processChars: { bne !- !e: sta.z bitmask + lda #STATUS_FREE ldy #OFFSET_STRUCT_PROCESSINGSPRITE_STATUS - lda (processing),y - cmp #STATUS_FREE + cmp (processing),y bne !__b2+ jmp __b2 !__b2: diff --git a/src/test/ref/complex/clearscreen/clearscreen.log b/src/test/ref/complex/clearscreen/clearscreen.log index 929885b20..8f2e2c510 100644 --- a/src/test/ref/complex/clearscreen/clearscreen.log +++ b/src/test/ref/complex/clearscreen/clearscreen.log @@ -5641,9 +5641,9 @@ getCharToProcess: { // getCharToProcess::@2 __b2: // [122] if(*((byte*) getCharToProcess::screen_line#4 + (byte) getCharToProcess::x#2)==(byte) ' ') goto getCharToProcess::@11 -- pbuz1_derefidx_vbuz2_eq_vbuc1_then_la1 + lda #' ' ldy.z x - lda (screen_line),y - cmp #' ' + cmp (screen_line),y beq __b11 jmp __b4 // getCharToProcess::@4 @@ -6622,9 +6622,9 @@ processChars: { !e: sta.z bitmask // [263] if(*((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)==(const byte) STATUS_FREE) goto processChars::@2 -- pbuz1_derefidx_vbuc1_eq_vbuc2_then_la1 + lda #STATUS_FREE ldy #OFFSET_STRUCT_PROCESSINGSPRITE_STATUS - lda (processing),y - cmp #STATUS_FREE + cmp (processing),y beq __b2_from___b1 jmp __b10 // processChars::@10 @@ -8567,8 +8567,8 @@ getCharToProcess: { // getCharToProcess::@2 __b2: // [122] if(*((byte*) getCharToProcess::screen_line#4 + (byte) getCharToProcess::x#2)==(byte) ' ') goto getCharToProcess::@11 -- pbuz1_derefidx_vbuyy_eq_vbuc1_then_la1 - lda (screen_line),y - cmp #' ' + lda #' ' + cmp (screen_line),y beq __b11 jmp __b4 // getCharToProcess::@4 @@ -9456,9 +9456,9 @@ processChars: { !e: sta.z bitmask // [263] if(*((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)==(const byte) STATUS_FREE) goto processChars::@2 -- pbuz1_derefidx_vbuc1_eq_vbuc2_then_la1 + lda #STATUS_FREE ldy #OFFSET_STRUCT_PROCESSINGSPRITE_STATUS - lda (processing),y - cmp #STATUS_FREE + cmp (processing),y beq __b2_from___b1 jmp __b10 // processChars::@10 @@ -11394,8 +11394,8 @@ getCharToProcess: { __b2: // if(screen_line[x]!=' ') // [122] if(*((byte*) getCharToProcess::screen_line#4 + (byte) getCharToProcess::x#2)==(byte) ' ') goto getCharToProcess::@11 -- pbuz1_derefidx_vbuyy_eq_vbuc1_then_la1 - lda (screen_line),y - cmp #' ' + lda #' ' + cmp (screen_line),y bne !__b11+ jmp __b11 !__b11: @@ -12269,9 +12269,9 @@ processChars: { sta.z bitmask // if(processing->status!=STATUS_FREE) // [263] if(*((byte*)(struct ProcessingSprite*) processChars::processing#0 + (const byte) OFFSET_STRUCT_PROCESSINGSPRITE_STATUS)==(const byte) STATUS_FREE) goto processChars::@2 -- pbuz1_derefidx_vbuc1_eq_vbuc2_then_la1 + lda #STATUS_FREE ldy #OFFSET_STRUCT_PROCESSINGSPRITE_STATUS - lda (processing),y - cmp #STATUS_FREE + cmp (processing),y bne !__b2+ jmp __b2 !__b2: diff --git a/src/test/ref/loop-break-nested.asm b/src/test/ref/loop-break-nested.asm index efc1acd00..ea119845b 100644 --- a/src/test/ref/loop-break-nested.asm +++ b/src/test/ref/loop-break-nested.asm @@ -26,10 +26,9 @@ main: { b1: ldy #0 __b3: - lda (line),y - cmp #'a' - beq __b5 lda #'a' + cmp (line),y + beq __b5 sta (line),y iny cpy #$28 diff --git a/src/test/ref/loop-break-nested.log b/src/test/ref/loop-break-nested.log index aba36191b..30bd37e31 100644 --- a/src/test/ref/loop-break-nested.log +++ b/src/test/ref/loop-break-nested.log @@ -296,9 +296,9 @@ main: { // main::@3 __b3: // [10] if(*((byte*) main::line#2 + (byte) main::i#2)==(byte) 'a') goto main::@5 -- pbuz1_derefidx_vbuz2_eq_vbuc1_then_la1 + lda #'a' ldy.z i - lda (line),y - cmp #'a' + cmp (line),y beq __b5 jmp __b4 // main::@4 @@ -424,8 +424,8 @@ main: { // main::@3 __b3: // [10] if(*((byte*) main::line#2 + (byte) main::i#2)==(byte) 'a') goto main::@5 -- pbuz1_derefidx_vbuyy_eq_vbuc1_then_la1 - lda (line),y - cmp #'a' + lda #'a' + cmp (line),y beq __b5 jmp __b4 // main::@4 @@ -487,6 +487,8 @@ Relabelling long label __b3_from___b2 to b1 Succesful ASM optimization Pass5RelabelLongLabels Removing instruction jmp __b3 Succesful ASM optimization Pass5NextJumpElimination +Removing instruction lda #'a' +Succesful ASM optimization Pass5UnnecesaryLoadElimination Removing instruction __b1: Succesful ASM optimization Pass5UnusedLabelElimination @@ -513,7 +515,7 @@ reg byte y [ main::i#2 main::i#1 ] FINAL ASSEMBLER -Score: 3256 +Score: 3056 // File Comments // Tests break statement in a simple loop @@ -572,13 +574,12 @@ main: { __b3: // if(line[i]=='a') // [10] if(*((byte*) main::line#2 + (byte) main::i#2)==(byte) 'a') goto main::@5 -- pbuz1_derefidx_vbuyy_eq_vbuc1_then_la1 - lda (line),y - cmp #'a' + lda #'a' + cmp (line),y beq __b5 // main::@4 // line[i] = 'a' // [11] *((byte*) main::line#2 + (byte) main::i#2) ← (byte) 'a' -- pbuz1_derefidx_vbuyy=vbuc1 - lda #'a' sta (line),y // for( byte i: 0..39) // [12] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy diff --git a/src/test/ref/textbox.asm b/src/test/ref/textbox.asm index 244d6e698..296182fed 100644 --- a/src/test/ref/textbox.asm +++ b/src/test/ref/textbox.asm @@ -159,8 +159,8 @@ textbox: { iny ldx #0 __b3: - lda (text),y - cmp #$20 + lda #$20 + cmp (text),y beq __b5 lda (text),y cmp #0 diff --git a/src/test/ref/textbox.log b/src/test/ref/textbox.log index 206373e0e..38cb9be88 100644 --- a/src/test/ref/textbox.log +++ b/src/test/ref/textbox.log @@ -2336,9 +2336,9 @@ textbox: { // textbox::@3 __b3: // [44] if(*((byte*) textbox::text#12 + (byte) textbox::ls#2)==(byte) $20) goto textbox::@5 -- pbuz1_derefidx_vbuz2_eq_vbuc1_then_la1 + lda #$20 ldy.z ls - lda (text),y - cmp #$20 + cmp (text),y beq __b5 jmp __b14 // textbox::@14 @@ -3652,8 +3652,8 @@ textbox: { // textbox::@3 __b3: // [44] if(*((byte*) textbox::text#12 + (byte) textbox::ls#2)==(byte) $20) goto textbox::@5 -- pbuz1_derefidx_vbuyy_eq_vbuc1_then_la1 - lda (text),y - cmp #$20 + lda #$20 + cmp (text),y beq __b5 jmp __b14 // textbox::@14 @@ -4825,8 +4825,8 @@ textbox: { __b3: // while (text[ls] != $20 && text[ls] != $00) // [44] if(*((byte*) textbox::text#12 + (byte) textbox::ls#2)==(byte) $20) goto textbox::@5 -- pbuz1_derefidx_vbuyy_eq_vbuc1_then_la1 - lda (text),y - cmp #$20 + lda #$20 + cmp (text),y beq __b5 // textbox::@14 // [45] if(*((byte*) textbox::text#12 + (byte) textbox::ls#2)!=(byte) 0) goto textbox::@4 -- pbuz1_derefidx_vbuyy_neq_0_then_la1