1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-02-06 13:31:05 +00:00

Added fragments from @Majikeyric

This commit is contained in:
jespergravgaard 2021-10-13 21:29:46 +02:00
parent fbb15ea4a3
commit a391f9cd76
31 changed files with 396 additions and 12 deletions

View File

@ -1,4 +1,4 @@
lda m1}
lda {m1}
sta {c1},x
lda {m1}+1
sta {c1}+1,x

View File

@ -1,4 +1,4 @@
lda m1}
lda {m1}
sta {c1},y
lda {m1}+1
sta {c1}+1,y

View File

@ -0,0 +1,20 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
sec
lda ($fe),y
sbc {m2}
sta ($fe),y
iny
lda ($fe),y
sbc {m2}+1
sta ($fe),y
iny
lda ($fe),y
sbc {m2}+2
sta ($fe),y
iny
lda ($fe),y
sbc {m2}+3
sta ($fe),y

View File

@ -0,0 +1,20 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
clc
lda ($fe),y
adc {m2}
sta ($fe),y
iny
lda ($fe),y
adc {m2}+1
sta ($fe),y
iny
lda ($fe),y
adc {m2}+2
sta ($fe),y
iny
lda ($fe),y
adc {m2}+3
sta ($fe),y

View File

@ -0,0 +1,24 @@
lda {m1}
sta $fc
lda {m1}+1
sta $fd
lda {m2}
sta $fe
lda {m2}+1
sta $ff
sec
lda ($fe),y
sbc {m3}
sta ($fc),y
iny
lda ($fe),y
sbc {m3}+1
sta ($fc),y
iny
lda ($fe),y
sbc {m3}+2
sta ($fc),y
iny
lda ($fe),y
sbc {m3}+3
sta ($fc),y

View File

@ -0,0 +1,24 @@
lda {m2}
sta $fc
lda {m2}+1
sta $fd
lda {m1}
sta $fe
lda {m1}+1
sta $ff
clc
lda ($fc),y
adc {m3}
sta ($fe),y
iny
lda ($fc),y
adc {m3}+1
sta ($fe),y
iny
lda ($fc),y
adc {m3}+2
sta ($fe),y
iny
lda ($fc),y
adc {m3}+3
sta ($fe),y

View File

@ -1,5 +1,5 @@
clc
adc {m2}
adc m2}
sta {m1}
lda #0
adc {m2}+1

View File

@ -0,0 +1,21 @@
lda {m1}
sta $fc
lda {m1}+1
sta $fd
lda {m2}
sta $fe
lda {m2}+1
sta $ff
lda ($fe),y
pha
iny
lda ($fe),y
pha
txa
tay
iny
pla
sta ($fc),y
dey
pla
sta ($fc),y

View File

@ -0,0 +1,17 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
lda ($fe),y
pha
iny
lda ($fe),y
pha
txa
tay
iny
pla
sta ($fe),y
dey
pla
sta ($fe),y

View File

@ -0,0 +1,12 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
sec
lda ($fe),y
sbc #<{c1}
sta ($fe),y
iny
lda ($fe),y
sbc #>{c1}
sta ($fe),y

View File

@ -0,0 +1,12 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
sec
lda ($fe),y
sbc {m2}
sta ($fe),y
iny
lda ($fe),y
sbc {m2}+1
sta ($fe),y

View File

@ -0,0 +1,12 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
clc
lda ($fe),y
adc #<{c1}
sta ($fe),y
iny
lda ($fe),y
adc #>{c1}
sta ($fe),y

View File

@ -0,0 +1,12 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
clc
lda ($fe),y
adc {m2}
sta ($fe),y
iny
lda ($fe),y
adc {m2}+1
sta ($fe),y

View File

@ -0,0 +1,16 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
lda {m2}
sta $fc
lda {m2}+1
sta $fd
sec
lda ($fc),y
sbc {m3}
sta ($fe),y
iny
lda ($fc),y
sbc {m3}+1
sta ($fe),y

View File

@ -0,0 +1,16 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
lda {m2}
sta $fc
lda {m2}+1
sta $fd
clc
lda ($fc),y
adc {m3}
sta ($fe),y
iny
lda ($fc),y
adc {m3}+1
sta ($fe),y

View File

@ -0,0 +1,9 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
lda #<{c2}
sta ($fe),y
iny
lda #>{c2}
sta ($fe),y

View File

@ -0,0 +1,9 @@
lda {m1}
sta $fe
lda {m1}+1
sta $ff
lda {m2}
sta ($fe),y
iny
lda {m2}+1
sta ($fe),y

View File

@ -0,0 +1 @@
sta {m1}

View File

@ -0,0 +1,7 @@
lda {m2}
sta $fe
lda {m2}+1
sta $ff
lda ($fe),y
cmp {m1}
beq {la1}

View File

@ -0,0 +1,15 @@
lda {m2}
sta $fe
lda {m2}+1
sta $ff
lda ($fe),y
sta {m1}
iny
lda ($fe),y
sta {m1}+1
iny
lda ($fe),y
sta {m1}+2
iny
lda ($fe),y
sta {m1}+3

View File

@ -0,0 +1,20 @@
lda {m2}
sta $fe
lda {m2}+1
sta $ff
clc
lda ($fe),y
adc #<{c1}
sta {m1}
iny
lda ($fe),y
adc #>{c1}
sta {m1}+1
iny
lda ($fe),y
adc #<{c1}>>16
sta {m1}+2
iny
lda ($fe),y
adc #>{c1}>>16
sta {m1}+3

View File

@ -0,0 +1,5 @@
lda {m1}
ora {m1}+1
ora {m1}+2
ora {m1}+3
bne {la1}

View File

@ -0,0 +1,10 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1
ora #$7f
bmi !+
lda #0
!:
sta {m1}+2
sta {m1}+3

View File

@ -0,0 +1,4 @@
lda {m2}
sta {m1}
lda {m2}+1
sta {m1}+1

View File

@ -0,0 +1,9 @@
lda {m2}
sta $fe
lda {m2}+1
sta $ff
lda ($fe),y
sta {m1}
iny
lda ($fe),y
sta {m1}+1

View File

@ -0,0 +1,17 @@
lda {m2}
sta $fe
lda {m2}+1
sta $ff
clc
iny
lda ($fe),y
pha
dey
lda ($fe),y
ldy #{c2}
adc ($fe),y
sta {m1}
iny
pla
adc ($fe),y
sta {m1}+1

View File

@ -0,0 +1,17 @@
sta $fd
lda {m2}
sta $fe
lda {m2}+1
sta $ff
lda ($fe),y
clc
adc $fd
sta {m1}
iny
lda $fd
ora #$7f
bmi !+
lda #0
!:
adc ($fe),y
sta {m1}+1

View File

@ -0,0 +1,24 @@
lda {m2}
sta $fc
lda {m2}+1
sta $fd
lda {m3}
sta $fe
lda {m3}+1
sta $ff
iny
lda ($fe),y
pha
dey
lda ($fe),y
pha
txa
tay
pla
sec
sbc ($fc),y
sta {m1}
iny
pla
sbc ($fc),y
sta {m1}+1

View File

@ -0,0 +1,24 @@
lda {m2}
sta $fc
lda {m2}+1
sta $fd
lda {m3}
sta $fe
lda {m3}+1
sta $ff
iny
lda ($fe),y
pha
dey
lda ($fe),y
pha
txa
tay
pla
clc
adc ($fc),y
sta {m1}
iny
pla
adc ($fc),y
sta {m1}+1

View File

@ -273,14 +273,20 @@ public class KickC implements Callable<Integer> {
compiler.getLog().setVerboseFragmentLog(true);
}
compiler.getLog().setSysOut(true);
final AsmFragmentTemplateMasterSynthesizer masterSynthesizer = compiler.getAsmFragmentMasterSynthesizer();
final AsmFragmentTemplateSynthesizer cpuSynthesizer = masterSynthesizer.getSynthesizer(program.getTargetCpu());
Collection<AsmFragmentTemplate> fragmentTemplates = cpuSynthesizer.getBestTemplates(fragment, compiler.getLog());
for(AsmFragmentTemplate fragmentTemplate : fragmentTemplates) {
AsmFragmentTemplateUsages.logTemplate(compiler.getLog(), fragmentTemplate, "");
}
if(fragmentTemplates.size()==0) {
compiler.getLog().append("Cannot create "+fragment);
try {
final AsmFragmentTemplateMasterSynthesizer masterSynthesizer = compiler.getAsmFragmentMasterSynthesizer();
final AsmFragmentTemplateSynthesizer cpuSynthesizer = masterSynthesizer.getSynthesizer(program.getTargetCpu());
Collection<AsmFragmentTemplate> fragmentTemplates = cpuSynthesizer.getBestTemplates(fragment, compiler.getLog());
for(AsmFragmentTemplate fragmentTemplate : fragmentTemplates) {
AsmFragmentTemplateUsages.logTemplate(compiler.getLog(), fragmentTemplate, "");
}
if(fragmentTemplates.size() == 0) {
compiler.getLog().append("Cannot create " + fragment);
return COMPILE_ERROR;
}
} catch (CompileError e) {
// Print the error and exit with compile error
System.err.println(e.format());
return COMPILE_ERROR;
}
}
@ -295,7 +301,7 @@ public class KickC implements Callable<Integer> {
if(outputDir != null)
program.getOutputFileManager().setOutputDir(outputDir);
if(outputFileName!=null)
if(outputFileName != null)
program.getOutputFileManager().setOutputFileName(outputFileName);
if(optimizeNoUplift)

View File

@ -18,6 +18,7 @@ public class AsmParser {
KickCLexer kickCLexer = new KickCLexer(fragmentCharStream, cParser);
kickCLexer.pushMode(KickCLexer.ASM_MODE);
KickCParser kickCParser = new KickCParser(new CommonTokenStream(kickCLexer), cParser);
kickCParser.removeErrorListeners();
kickCParser.addErrorListener(new BaseErrorListener() {
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {