mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-22 16:33:48 +00:00
Added support for #pragma emulator() specifying which emulator to execute.
This commit is contained in:
parent
7e859fa8ae
commit
c3a9ced0f5
@ -393,7 +393,19 @@ public class KickC implements Callable<Void> {
|
||||
// Assemble the asm-file if instructed
|
||||
String prgFileName = outputFileNameBase + ".prg";
|
||||
Path prgPath = outputDir.resolve(prgFileName);
|
||||
if(assemble || execute || debug || (emulator != null)) {
|
||||
|
||||
// Find emulator - if set by #pragma
|
||||
if(emulator == null) {
|
||||
if(program.getEmulatorCommand() != null)
|
||||
emulator = program.getEmulatorCommand();
|
||||
else if(debug) {
|
||||
emulator = "C64Debugger";
|
||||
} else if(execute) {
|
||||
emulator = "x64sc";
|
||||
}
|
||||
}
|
||||
|
||||
if(assemble || emulator != null) {
|
||||
Path kasmLogPath = outputDir.resolve(outputFileNameBase + ".klog");
|
||||
System.out.println("Assembling to " + prgPath.toString());
|
||||
String[] assembleCommand = {asmPath.toString(), "-log", kasmLogPath.toString(), "-o", prgPath.toString(), "-vicesymbols", "-showmem", "-debugdump"};
|
||||
@ -422,26 +434,22 @@ public class KickC implements Callable<Void> {
|
||||
}
|
||||
}
|
||||
|
||||
if(debug) {
|
||||
emulator = "C64Debugger";
|
||||
}
|
||||
if(execute) {
|
||||
emulator = "x64sc";
|
||||
}
|
||||
String emuOptions = "";
|
||||
if(emulator.equals("C64Debugger")) {
|
||||
Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs");
|
||||
emuOptions = "-symbols " + viceSymbolsPath + " -wait 2500" + " ";
|
||||
}
|
||||
// The program names used by VICE emulators
|
||||
List<String> viceEmus = Arrays.asList("x64", "x64sc", "x128", "x64dtv", "xcbm2", "xcbm5x0", "xpet", "xplus4", "xscpu64", "xvic");
|
||||
if(viceEmus.contains(emulator)) {
|
||||
Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs");
|
||||
emuOptions = "-moncommands " + viceSymbolsPath.toAbsolutePath().toString() + " ";
|
||||
}
|
||||
|
||||
// Execute the prg-file if instructed
|
||||
if(emulator != null) {
|
||||
|
||||
// Find commandline options for the emulator
|
||||
String emuOptions = "";
|
||||
if(emulator.equals("C64Debugger")) {
|
||||
Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs");
|
||||
emuOptions = "-symbols " + viceSymbolsPath + " -wait 2500" + " ";
|
||||
}
|
||||
// The program names used by VICE emulators
|
||||
List<String> viceEmus = Arrays.asList("x64", "x64sc", "x128", "x64dtv", "xcbm2", "xcbm5x0", "xpet", "xplus4", "xscpu64", "xvic");
|
||||
if(viceEmus.contains(emulator)) {
|
||||
Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs");
|
||||
emuOptions = "-moncommands " + viceSymbolsPath.toAbsolutePath().toString() + " ";
|
||||
}
|
||||
|
||||
System.out.println("Executing " + prgPath + " using " + emulator);
|
||||
String executeCommand = emulator + " " + emuOptions + prgPath.toAbsolutePath().toString();
|
||||
if(verbose) {
|
||||
|
@ -49,6 +49,8 @@ public class Program {
|
||||
private Path linkScriptFilePath;
|
||||
/** Body to any custom link script file used for linking (STATIC) */
|
||||
private String linkScriptBody;
|
||||
/** The program name for the emulator to pass the compiled program to. */
|
||||
private String emulatorCommand;
|
||||
|
||||
/** Absolute start address of the code. Null to start ad 0x080d. PASS 0-5 (STATIC) */
|
||||
private Number programPc;
|
||||
@ -506,6 +508,14 @@ public class Program {
|
||||
return programPc;
|
||||
}
|
||||
|
||||
public void setEmulatorCommand(String emulatorCommand) {
|
||||
this.emulatorCommand = emulatorCommand;
|
||||
}
|
||||
|
||||
public String getEmulatorCommand() {
|
||||
return emulatorCommand;
|
||||
}
|
||||
|
||||
public CompileLog getLog() {
|
||||
return log;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ RESERVE:'reserve' ;
|
||||
PC:'pc';
|
||||
TARGET:'target';
|
||||
LINK:'link';
|
||||
EMULATOR:'emulator';
|
||||
CPU:'cpu';
|
||||
CODESEG:'code_seg';
|
||||
DATASEG:'data_seg';
|
||||
|
@ -41,124 +41,125 @@ RESERVE=40
|
||||
PC=41
|
||||
TARGET=42
|
||||
LINK=43
|
||||
CPU=44
|
||||
CODESEG=45
|
||||
DATASEG=46
|
||||
ENCODING=47
|
||||
CONST=48
|
||||
EXTERN=49
|
||||
EXPORT=50
|
||||
ALIGN=51
|
||||
INLINE=52
|
||||
VOLATILE=53
|
||||
STATIC=54
|
||||
INTERRUPT=55
|
||||
REGISTER=56
|
||||
ADDRESS=57
|
||||
ADDRESS_ZEROPAGE=58
|
||||
ADDRESS_MAINMEM=59
|
||||
FORM_SSA=60
|
||||
FORM_MA=61
|
||||
INTRINSIC=62
|
||||
CALLING=63
|
||||
CALLINGCONVENTION=64
|
||||
VARMODEL=65
|
||||
IF=66
|
||||
ELSE=67
|
||||
WHILE=68
|
||||
DO=69
|
||||
FOR=70
|
||||
SWITCH=71
|
||||
RETURN=72
|
||||
BREAK=73
|
||||
CONTINUE=74
|
||||
ASM=75
|
||||
DEFAULT=76
|
||||
CASE=77
|
||||
STRUCT=78
|
||||
ENUM=79
|
||||
SIZEOF=80
|
||||
TYPEID=81
|
||||
DEFINED=82
|
||||
KICKASM=83
|
||||
RESOURCE=84
|
||||
USES=85
|
||||
CLOBBERS=86
|
||||
BYTES=87
|
||||
CYCLES=88
|
||||
LOGIC_NOT=89
|
||||
SIGNEDNESS=90
|
||||
SIMPLETYPE=91
|
||||
BOOLEAN=92
|
||||
KICKASM_BODY=93
|
||||
IMPORT=94
|
||||
INCLUDE=95
|
||||
PRAGMA=96
|
||||
DEFINE=97
|
||||
DEFINE_CONTINUE=98
|
||||
UNDEF=99
|
||||
IFDEF=100
|
||||
IFNDEF=101
|
||||
IFIF=102
|
||||
ELIF=103
|
||||
IFELSE=104
|
||||
ENDIF=105
|
||||
NUMBER=106
|
||||
NUMFLOAT=107
|
||||
BINFLOAT=108
|
||||
DECFLOAT=109
|
||||
HEXFLOAT=110
|
||||
NUMINT=111
|
||||
BININTEGER=112
|
||||
DECINTEGER=113
|
||||
HEXINTEGER=114
|
||||
NAME=115
|
||||
STRING=116
|
||||
CHAR=117
|
||||
WS=118
|
||||
COMMENT_LINE=119
|
||||
COMMENT_BLOCK=120
|
||||
ASM_BYTE=121
|
||||
ASM_MNEMONIC=122
|
||||
ASM_IMM=123
|
||||
ASM_COLON=124
|
||||
ASM_COMMA=125
|
||||
ASM_PAR_BEGIN=126
|
||||
ASM_PAR_END=127
|
||||
ASM_BRACKET_BEGIN=128
|
||||
ASM_BRACKET_END=129
|
||||
ASM_DOT=130
|
||||
ASM_SHIFT_LEFT=131
|
||||
ASM_SHIFT_RIGHT=132
|
||||
ASM_PLUS=133
|
||||
ASM_MINUS=134
|
||||
ASM_LESS_THAN=135
|
||||
ASM_GREATER_THAN=136
|
||||
ASM_MULTIPLY=137
|
||||
ASM_DIVIDE=138
|
||||
ASM_CURLY_BEGIN=139
|
||||
ASM_CURLY_END=140
|
||||
ASM_NUMBER=141
|
||||
ASM_NUMFLOAT=142
|
||||
ASM_BINFLOAT=143
|
||||
ASM_DECFLOAT=144
|
||||
ASM_HEXFLOAT=145
|
||||
ASM_NUMINT=146
|
||||
ASM_BININTEGER=147
|
||||
ASM_DECINTEGER=148
|
||||
ASM_HEXINTEGER=149
|
||||
ASM_CHAR=150
|
||||
ASM_MULTI_REL=151
|
||||
ASM_MULTI_NAME=152
|
||||
ASM_NAME=153
|
||||
ASM_WS=154
|
||||
ASM_COMMENT_LINE=155
|
||||
ASM_COMMENT_BLOCK=156
|
||||
IMPORT_SYSTEMFILE=157
|
||||
IMPORT_LOCALFILE=158
|
||||
IMPORT_WS=159
|
||||
IMPORT_COMMENT_LINE=160
|
||||
IMPORT_COMMENT_BLOCK=161
|
||||
EMULATOR=44
|
||||
CPU=45
|
||||
CODESEG=46
|
||||
DATASEG=47
|
||||
ENCODING=48
|
||||
CONST=49
|
||||
EXTERN=50
|
||||
EXPORT=51
|
||||
ALIGN=52
|
||||
INLINE=53
|
||||
VOLATILE=54
|
||||
STATIC=55
|
||||
INTERRUPT=56
|
||||
REGISTER=57
|
||||
ADDRESS=58
|
||||
ADDRESS_ZEROPAGE=59
|
||||
ADDRESS_MAINMEM=60
|
||||
FORM_SSA=61
|
||||
FORM_MA=62
|
||||
INTRINSIC=63
|
||||
CALLING=64
|
||||
CALLINGCONVENTION=65
|
||||
VARMODEL=66
|
||||
IF=67
|
||||
ELSE=68
|
||||
WHILE=69
|
||||
DO=70
|
||||
FOR=71
|
||||
SWITCH=72
|
||||
RETURN=73
|
||||
BREAK=74
|
||||
CONTINUE=75
|
||||
ASM=76
|
||||
DEFAULT=77
|
||||
CASE=78
|
||||
STRUCT=79
|
||||
ENUM=80
|
||||
SIZEOF=81
|
||||
TYPEID=82
|
||||
DEFINED=83
|
||||
KICKASM=84
|
||||
RESOURCE=85
|
||||
USES=86
|
||||
CLOBBERS=87
|
||||
BYTES=88
|
||||
CYCLES=89
|
||||
LOGIC_NOT=90
|
||||
SIGNEDNESS=91
|
||||
SIMPLETYPE=92
|
||||
BOOLEAN=93
|
||||
KICKASM_BODY=94
|
||||
IMPORT=95
|
||||
INCLUDE=96
|
||||
PRAGMA=97
|
||||
DEFINE=98
|
||||
DEFINE_CONTINUE=99
|
||||
UNDEF=100
|
||||
IFDEF=101
|
||||
IFNDEF=102
|
||||
IFIF=103
|
||||
ELIF=104
|
||||
IFELSE=105
|
||||
ENDIF=106
|
||||
NUMBER=107
|
||||
NUMFLOAT=108
|
||||
BINFLOAT=109
|
||||
DECFLOAT=110
|
||||
HEXFLOAT=111
|
||||
NUMINT=112
|
||||
BININTEGER=113
|
||||
DECINTEGER=114
|
||||
HEXINTEGER=115
|
||||
NAME=116
|
||||
STRING=117
|
||||
CHAR=118
|
||||
WS=119
|
||||
COMMENT_LINE=120
|
||||
COMMENT_BLOCK=121
|
||||
ASM_BYTE=122
|
||||
ASM_MNEMONIC=123
|
||||
ASM_IMM=124
|
||||
ASM_COLON=125
|
||||
ASM_COMMA=126
|
||||
ASM_PAR_BEGIN=127
|
||||
ASM_PAR_END=128
|
||||
ASM_BRACKET_BEGIN=129
|
||||
ASM_BRACKET_END=130
|
||||
ASM_DOT=131
|
||||
ASM_SHIFT_LEFT=132
|
||||
ASM_SHIFT_RIGHT=133
|
||||
ASM_PLUS=134
|
||||
ASM_MINUS=135
|
||||
ASM_LESS_THAN=136
|
||||
ASM_GREATER_THAN=137
|
||||
ASM_MULTIPLY=138
|
||||
ASM_DIVIDE=139
|
||||
ASM_CURLY_BEGIN=140
|
||||
ASM_CURLY_END=141
|
||||
ASM_NUMBER=142
|
||||
ASM_NUMFLOAT=143
|
||||
ASM_BINFLOAT=144
|
||||
ASM_DECFLOAT=145
|
||||
ASM_HEXFLOAT=146
|
||||
ASM_NUMINT=147
|
||||
ASM_BININTEGER=148
|
||||
ASM_DECINTEGER=149
|
||||
ASM_HEXINTEGER=150
|
||||
ASM_CHAR=151
|
||||
ASM_MULTI_REL=152
|
||||
ASM_MULTI_NAME=153
|
||||
ASM_NAME=154
|
||||
ASM_WS=155
|
||||
ASM_COMMENT_LINE=156
|
||||
ASM_COMMENT_BLOCK=157
|
||||
IMPORT_SYSTEMFILE=158
|
||||
IMPORT_LOCALFILE=159
|
||||
IMPORT_WS=160
|
||||
IMPORT_COMMENT_LINE=161
|
||||
IMPORT_COMMENT_BLOCK=162
|
||||
';'=8
|
||||
'..'=11
|
||||
'...'=12
|
||||
@ -183,61 +184,62 @@ IMPORT_COMMENT_BLOCK=161
|
||||
'pc'=41
|
||||
'target'=42
|
||||
'link'=43
|
||||
'cpu'=44
|
||||
'code_seg'=45
|
||||
'data_seg'=46
|
||||
'encoding'=47
|
||||
'const'=48
|
||||
'extern'=49
|
||||
'export'=50
|
||||
'align'=51
|
||||
'inline'=52
|
||||
'volatile'=53
|
||||
'static'=54
|
||||
'interrupt'=55
|
||||
'register'=56
|
||||
'__address'=57
|
||||
'__zp'=58
|
||||
'__mem'=59
|
||||
'__ssa'=60
|
||||
'__ma'=61
|
||||
'__intrinsic'=62
|
||||
'calling'=63
|
||||
'var_model'=65
|
||||
'if'=66
|
||||
'else'=67
|
||||
'while'=68
|
||||
'do'=69
|
||||
'for'=70
|
||||
'switch'=71
|
||||
'return'=72
|
||||
'break'=73
|
||||
'continue'=74
|
||||
'asm'=75
|
||||
'default'=76
|
||||
'case'=77
|
||||
'struct'=78
|
||||
'enum'=79
|
||||
'sizeof'=80
|
||||
'typeid'=81
|
||||
'defined'=82
|
||||
'kickasm'=83
|
||||
'resource'=84
|
||||
'uses'=85
|
||||
'clobbers'=86
|
||||
'bytes'=87
|
||||
'cycles'=88
|
||||
'!'=89
|
||||
'#import'=94
|
||||
'#include'=95
|
||||
'#pragma'=96
|
||||
'#define'=97
|
||||
'#undef'=99
|
||||
'#ifdef'=100
|
||||
'#ifndef'=101
|
||||
'#if'=102
|
||||
'#elif'=103
|
||||
'#else'=104
|
||||
'#endif'=105
|
||||
'.byte'=121
|
||||
'#'=123
|
||||
'emulator'=44
|
||||
'cpu'=45
|
||||
'code_seg'=46
|
||||
'data_seg'=47
|
||||
'encoding'=48
|
||||
'const'=49
|
||||
'extern'=50
|
||||
'export'=51
|
||||
'align'=52
|
||||
'inline'=53
|
||||
'volatile'=54
|
||||
'static'=55
|
||||
'interrupt'=56
|
||||
'register'=57
|
||||
'__address'=58
|
||||
'__zp'=59
|
||||
'__mem'=60
|
||||
'__ssa'=61
|
||||
'__ma'=62
|
||||
'__intrinsic'=63
|
||||
'calling'=64
|
||||
'var_model'=66
|
||||
'if'=67
|
||||
'else'=68
|
||||
'while'=69
|
||||
'do'=70
|
||||
'for'=71
|
||||
'switch'=72
|
||||
'return'=73
|
||||
'break'=74
|
||||
'continue'=75
|
||||
'asm'=76
|
||||
'default'=77
|
||||
'case'=78
|
||||
'struct'=79
|
||||
'enum'=80
|
||||
'sizeof'=81
|
||||
'typeid'=82
|
||||
'defined'=83
|
||||
'kickasm'=84
|
||||
'resource'=85
|
||||
'uses'=86
|
||||
'clobbers'=87
|
||||
'bytes'=88
|
||||
'cycles'=89
|
||||
'!'=90
|
||||
'#import'=95
|
||||
'#include'=96
|
||||
'#pragma'=97
|
||||
'#define'=98
|
||||
'#undef'=100
|
||||
'#ifdef'=101
|
||||
'#ifndef'=102
|
||||
'#if'=103
|
||||
'#elif'=104
|
||||
'#else'=105
|
||||
'#endif'=106
|
||||
'.byte'=122
|
||||
'#'=124
|
||||
|
@ -151,6 +151,7 @@ globalDirective
|
||||
| (PRAGMA TARGET) PAR_BEGIN NAME PAR_END #globalDirectivePlatform
|
||||
| (PRAGMA CPU) PAR_BEGIN NAME PAR_END #globalDirectiveCpu
|
||||
| (PRAGMA LINK) PAR_BEGIN STRING PAR_END #globalDirectiveLinkScript
|
||||
| (PRAGMA EMULATOR) PAR_BEGIN STRING PAR_END #globalDirectiveEmulator
|
||||
| (PRAGMA CODESEG) PAR_BEGIN NAME PAR_END #globalDirectiveCodeSeg
|
||||
| (PRAGMA DATASEG) PAR_BEGIN NAME PAR_END #globalDirectiveDataSeg
|
||||
| (PRAGMA ENCODING) PAR_BEGIN NAME PAR_END #globalDirectiveEncoding
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -159,6 +159,7 @@ IMPORT_LOCALFILE=158
|
||||
IMPORT_WS=159
|
||||
IMPORT_COMMENT_LINE=160
|
||||
IMPORT_COMMENT_BLOCK=161
|
||||
EMULATOR=162
|
||||
';'=8
|
||||
'..'=11
|
||||
'...'=12
|
||||
|
@ -577,6 +577,18 @@ public class KickCParserBaseListener implements KickCParserListener {
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitGlobalDirectiveLinkScript(KickCParser.GlobalDirectiveLinkScriptContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -342,6 +342,13 @@ public class KickCParserBaseVisitor<T> extends AbstractParseTreeVisitor<T> imple
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitGlobalDirectiveLinkScript(KickCParser.GlobalDirectiveLinkScriptContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -531,6 +531,18 @@ public interface KickCParserListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitGlobalDirectiveLinkScript(KickCParser.GlobalDirectiveLinkScriptContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code globalDirectiveEmulator}
|
||||
* labeled alternative in {@link KickCParser#globalDirective}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by the {@code globalDirectiveEmulator}
|
||||
* labeled alternative in {@link KickCParser#globalDirective}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by the {@code globalDirectiveCodeSeg}
|
||||
* labeled alternative in {@link KickCParser#globalDirective}.
|
||||
|
@ -320,6 +320,13 @@ public interface KickCParserVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitGlobalDirectiveLinkScript(KickCParser.GlobalDirectiveLinkScriptContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code globalDirectiveEmulator}
|
||||
* labeled alternative in {@link KickCParser#globalDirective}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code globalDirectiveCodeSeg}
|
||||
* labeled alternative in {@link KickCParser#globalDirective}.
|
||||
|
@ -136,6 +136,14 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitGlobalDirectiveEmulator(KickCParser.GlobalDirectiveEmulatorContext ctx) {
|
||||
String emuName = ctx.STRING().getText();
|
||||
emuName = emuName.substring(1, emuName.length() - 1);
|
||||
program.setEmulatorCommand(emuName);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitGlobalDirectiveReserve(KickCParser.GlobalDirectiveReserveContext ctx) {
|
||||
List<Integer> reservedZps = new ArrayList<>();
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Random walk with color fading for Commodore Plus/4 / C16
|
||||
#pragma link("plus4.ld")
|
||||
#pragma emulator("xplus4")
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
Loading…
Reference in New Issue
Block a user