mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-08 17:54:40 +00:00
Renamed long branch fix label.
This commit is contained in:
parent
aec15a3125
commit
1feed93b43
@ -43,14 +43,13 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform
|
* Detect if any branch distance is to long, and fix it by rewriting the branch if it is.
|
||||||
* @return
|
* @return true if any branch was rewritten
|
||||||
*/
|
*/
|
||||||
private boolean step() {
|
private boolean step() {
|
||||||
// Reindex ASM lines
|
// Reindex ASM lines
|
||||||
new Pass5ReindexAsmLines(getProgram()).optimize();
|
new Pass5ReindexAsmLines(getProgram()).optimize();
|
||||||
|
|
||||||
|
|
||||||
// Create a temporary directory for the ASM file
|
// Create a temporary directory for the ASM file
|
||||||
try {
|
try {
|
||||||
tmpDir = Files.createTempDirectory("kickc");
|
tmpDir = Files.createTempDirectory("kickc");
|
||||||
@ -68,7 +67,6 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
|||||||
throw new CompileError("Error writing ASM temp file.", e);
|
throw new CompileError("Error writing ASM temp file.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Compile using KickAssembler - catch the output in a String
|
// Compile using KickAssembler - catch the output in a String
|
||||||
File asmFile = getTmpFile(fileName, ".asm");
|
File asmFile = getTmpFile(fileName, ".asm");
|
||||||
File asmPrgFile = getTmpFile(fileName, ".prg");
|
File asmPrgFile = getTmpFile(fileName, ".prg");
|
||||||
@ -78,7 +76,7 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
|||||||
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
|
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
|
||||||
String output = kickAssOut.toString();
|
String output = kickAssOut.toString();
|
||||||
|
|
||||||
// Look for a long branch error
|
// Look for a long branch distance error
|
||||||
if(asmRes != 0) {
|
if(asmRes != 0) {
|
||||||
String outputLines[] = output.split("\\r?\\n");
|
String outputLines[] = output.split("\\r?\\n");
|
||||||
for(int i = 0; i < outputLines.length; i++) {
|
for(int i = 0; i < outputLines.length; i++) {
|
||||||
@ -126,11 +124,11 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
|
|||||||
getLog().append("Fixing long branch ["+idx+"] "+asmLine.toString() + " to "+inverseType.getMnemnonic());
|
getLog().append("Fixing long branch ["+idx+"] "+asmLine.toString() + " to "+inverseType.getMnemnonic());
|
||||||
String branchDest = asmInstruction.getParameter();
|
String branchDest = asmInstruction.getParameter();
|
||||||
asmInstruction.setType(inverseType);
|
asmInstruction.setType(inverseType);
|
||||||
asmInstruction.setParameter("!b+");
|
asmInstruction.setParameter("!"+branchDest+"+");
|
||||||
AsmInstructionType jmpType = AsmInstructionSet.getInstructionType("jmp", AsmAddressingMode.ABS, false);
|
AsmInstructionType jmpType = AsmInstructionSet.getInstructionType("jmp", AsmAddressingMode.ABS, false);
|
||||||
AsmInstruction jmpInstruction = new AsmInstruction(jmpType, branchDest);
|
AsmInstruction jmpInstruction = new AsmInstruction(jmpType, branchDest);
|
||||||
asmSegment.addLineAfter(asmInstruction, jmpInstruction);
|
asmSegment.addLineAfter(asmInstruction, jmpInstruction);
|
||||||
asmSegment.addLineAfter(jmpInstruction, new AsmLabel("!b"));
|
asmSegment.addLineAfter(jmpInstruction, new AsmLabel("!"+branchDest));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,15 +126,15 @@ main: {
|
|||||||
!:
|
!:
|
||||||
lda chargen+1
|
lda chargen+1
|
||||||
cmp #>CHARGEN+$800
|
cmp #>CHARGEN+$800
|
||||||
bcs !b+
|
bcs !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
bne !+
|
bne !+
|
||||||
lda chargen
|
lda chargen
|
||||||
cmp #<CHARGEN+$800
|
cmp #<CHARGEN+$800
|
||||||
bcs !b+
|
bcs !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
!:
|
!:
|
||||||
lda #$37
|
lda #$37
|
||||||
sta PROCPORT
|
sta PROCPORT
|
||||||
|
@ -2495,15 +2495,15 @@ main: {
|
|||||||
//SEG76 [51] if((byte*) main::chargen#1<(const byte*) CHARGEN#0+(word/signed word/dword/signed dword) 2048) goto main::@1 [ main::chargen#1 main::charset4#1 ] ( main:2 [ main::chargen#1 main::charset4#1 ] ) -- pbuz1_lt_pbuc1_then_la1
|
//SEG76 [51] if((byte*) main::chargen#1<(const byte*) CHARGEN#0+(word/signed word/dword/signed dword) 2048) goto main::@1 [ main::chargen#1 main::charset4#1 ] ( main:2 [ main::chargen#1 main::charset4#1 ] ) -- pbuz1_lt_pbuc1_then_la1
|
||||||
lda chargen+1
|
lda chargen+1
|
||||||
cmp #>CHARGEN+$800
|
cmp #>CHARGEN+$800
|
||||||
bcs !b+
|
bcs !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
bne !+
|
bne !+
|
||||||
lda chargen
|
lda chargen
|
||||||
cmp #<CHARGEN+$800
|
cmp #<CHARGEN+$800
|
||||||
bcs !b+
|
bcs !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
!:
|
!:
|
||||||
//SEG77 main::@11
|
//SEG77 main::@11
|
||||||
//SEG78 [52] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2
|
//SEG78 [52] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2
|
||||||
|
@ -266,8 +266,8 @@ main: {
|
|||||||
sta SCREEN,x
|
sta SCREEN,x
|
||||||
inx
|
inx
|
||||||
cpx #$b
|
cpx #$b
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
@ -1423,9 +1423,9 @@ main: {
|
|||||||
inx
|
inx
|
||||||
//SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1
|
//SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1
|
||||||
cpx #$b
|
cpx #$b
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
//SEG19 main::@return
|
//SEG19 main::@return
|
||||||
//SEG20 [10] return [ ] ( main:2 [ ] )
|
//SEG20 [10] return [ ] ( main:2 [ ] )
|
||||||
rts
|
rts
|
||||||
|
@ -271,9 +271,9 @@ long2: {
|
|||||||
sta SCREEN,x
|
sta SCREEN,x
|
||||||
inx
|
inx
|
||||||
cpx #$b
|
cpx #$b
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
long1: {
|
long1: {
|
||||||
@ -540,8 +540,8 @@ long1: {
|
|||||||
sta SCREEN,x
|
sta SCREEN,x
|
||||||
inx
|
inx
|
||||||
cpx #$b
|
cpx #$b
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
@ -2526,9 +2526,9 @@ long2: {
|
|||||||
inx
|
inx
|
||||||
//SEG27 [14] if((byte) long2::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto long2::@1 [ long2::i#1 ] ( main:2::long2:7 [ long2::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1
|
//SEG27 [14] if((byte) long2::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto long2::@1 [ long2::i#1 ] ( main:2::long2:7 [ long2::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1
|
||||||
cpx #$b
|
cpx #$b
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
//SEG28 long2::@return
|
//SEG28 long2::@return
|
||||||
//SEG29 [15] return [ ] ( main:2::long2:7 [ ] )
|
//SEG29 [15] return [ ] ( main:2::long2:7 [ ] )
|
||||||
rts
|
rts
|
||||||
@ -2807,9 +2807,9 @@ long1: {
|
|||||||
inx
|
inx
|
||||||
//SEG39 [21] if((byte) long1::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto long1::@1 [ long1::i#1 ] ( main:2::long1:5 [ long1::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1
|
//SEG39 [21] if((byte) long1::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto long1::@1 [ long1::i#1 ] ( main:2::long1:5 [ long1::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1
|
||||||
cpx #$b
|
cpx #$b
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
//SEG40 long1::@return
|
//SEG40 long1::@return
|
||||||
//SEG41 [22] return [ ] ( main:2::long1:5 [ ] )
|
//SEG41 [22] return [ ] ( main:2::long1:5 [ ] )
|
||||||
rts
|
rts
|
||||||
|
@ -76,9 +76,9 @@ test_16u: {
|
|||||||
adc i
|
adc i
|
||||||
sta i
|
sta i
|
||||||
cmp #$c
|
cmp #$c
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
rts
|
rts
|
||||||
str: .text " / @"
|
str: .text " / @"
|
||||||
str1: .text " = @"
|
str1: .text " = @"
|
||||||
|
@ -5815,9 +5815,9 @@ test_16u: {
|
|||||||
sta i
|
sta i
|
||||||
//SEG84 [38] if((byte) test_16u::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 12) goto test_16u::@1 [ test_16u::i#1 div16u::rem#8 line_cursor#1 ] ( main:2::test_16u:9 [ test_16u::i#1 div16u::rem#8 line_cursor#1 ] ) -- vbuz1_neq_vbuc1_then_la1
|
//SEG84 [38] if((byte) test_16u::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 12) goto test_16u::@1 [ test_16u::i#1 div16u::rem#8 line_cursor#1 ] ( main:2::test_16u:9 [ test_16u::i#1 div16u::rem#8 line_cursor#1 ] ) -- vbuz1_neq_vbuc1_then_la1
|
||||||
cmp #$c
|
cmp #$c
|
||||||
beq !b+
|
beq !b1+
|
||||||
jmp b1
|
jmp b1
|
||||||
!b:
|
!b1:
|
||||||
//SEG85 test_16u::@return
|
//SEG85 test_16u::@return
|
||||||
//SEG86 [39] return [ ] ( main:2::test_16u:9 [ ] )
|
//SEG86 [39] return [ ] ( main:2::test_16u:9 [ ] )
|
||||||
rts
|
rts
|
||||||
|
Loading…
Reference in New Issue
Block a user