1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-27 04:49:27 +00:00

Changed memory area keywords to __zp / __mem / address(0xnn) / address(0xnnnn).

This commit is contained in:
Jesper Gravgaard 2019-10-17 01:27:56 +02:00
parent c215cfed28
commit 90b2077ac5
27 changed files with 1985 additions and 1665 deletions

View File

@ -78,9 +78,10 @@ EXTERN: 'extern' ;
EXPORT: 'export' ;
ALIGN: 'align' ;
REGISTER: 'register' ;
NOTREGISTER: 'notregister' ;
ZEROPAGE: '__zp' ;
MAINMEM: '__mem' ;
NOTREGISTER: '__notregister' ;
ADDRESS: '__address' ;
ADDRESS_ZEROPAGE: '__zp' ;
ADDRESS_MAINMEM: '__mem' ;
INLINE: 'inline' ;
VOLATILE: 'volatile' ;
INTERRUPT: 'interrupt' ;

File diff suppressed because it is too large Load Diff

View File

@ -52,91 +52,92 @@ EXPORT=51
ALIGN=52
REGISTER=53
NOTREGISTER=54
ZEROPAGE=55
MAINMEM=56
INLINE=57
VOLATILE=58
INTERRUPT=59
CALLING=60
CALLINGCONVENTION=61
IF=62
ELSE=63
WHILE=64
DO=65
FOR=66
SWITCH=67
RETURN=68
BREAK=69
CONTINUE=70
ASM=71
DEFAULT=72
CASE=73
STRUCT=74
ENUM=75
SIZEOF=76
TYPEID=77
KICKASM=78
RESOURCE=79
USES=80
CLOBBERS=81
BYTES=82
CYCLES=83
LOGIC_NOT=84
SIGNEDNESS=85
SIMPLETYPE=86
BOOLEAN=87
KICKASM_BODY=88
STRING=89
CHAR=90
NUMBER=91
NUMFLOAT=92
BINFLOAT=93
DECFLOAT=94
HEXFLOAT=95
NUMINT=96
BININTEGER=97
DECINTEGER=98
HEXINTEGER=99
NAME=100
WS=101
COMMENT_LINE=102
COMMENT_BLOCK=103
ASM_BYTE=104
ASM_MNEMONIC=105
ASM_IMM=106
ASM_COLON=107
ASM_COMMA=108
ASM_PAR_BEGIN=109
ASM_PAR_END=110
ASM_BRACKET_BEGIN=111
ASM_BRACKET_END=112
ASM_DOT=113
ASM_SHIFT_LEFT=114
ASM_SHIFT_RIGHT=115
ASM_PLUS=116
ASM_MINUS=117
ASM_LESS_THAN=118
ASM_GREATER_THAN=119
ASM_MULTIPLY=120
ASM_DIVIDE=121
ASM_CURLY_BEGIN=122
ASM_CURLY_END=123
ASM_NUMBER=124
ASM_NUMFLOAT=125
ASM_BINFLOAT=126
ASM_DECFLOAT=127
ASM_HEXFLOAT=128
ASM_NUMINT=129
ASM_BININTEGER=130
ASM_DECINTEGER=131
ASM_HEXINTEGER=132
ASM_CHAR=133
ASM_MULTI_REL=134
ASM_MULTI_NAME=135
ASM_NAME=136
ASM_WS=137
ASM_COMMENT_LINE=138
ASM_COMMENT_BLOCK=139
ADDRESS=55
ADDRESS_ZEROPAGE=56
ADDRESS_MAINMEM=57
INLINE=58
VOLATILE=59
INTERRUPT=60
CALLING=61
CALLINGCONVENTION=62
IF=63
ELSE=64
WHILE=65
DO=66
FOR=67
SWITCH=68
RETURN=69
BREAK=70
CONTINUE=71
ASM=72
DEFAULT=73
CASE=74
STRUCT=75
ENUM=76
SIZEOF=77
TYPEID=78
KICKASM=79
RESOURCE=80
USES=81
CLOBBERS=82
BYTES=83
CYCLES=84
LOGIC_NOT=85
SIGNEDNESS=86
SIMPLETYPE=87
BOOLEAN=88
KICKASM_BODY=89
STRING=90
CHAR=91
NUMBER=92
NUMFLOAT=93
BINFLOAT=94
DECFLOAT=95
HEXFLOAT=96
NUMINT=97
BININTEGER=98
DECINTEGER=99
HEXINTEGER=100
NAME=101
WS=102
COMMENT_LINE=103
COMMENT_BLOCK=104
ASM_BYTE=105
ASM_MNEMONIC=106
ASM_IMM=107
ASM_COLON=108
ASM_COMMA=109
ASM_PAR_BEGIN=110
ASM_PAR_END=111
ASM_BRACKET_BEGIN=112
ASM_BRACKET_END=113
ASM_DOT=114
ASM_SHIFT_LEFT=115
ASM_SHIFT_RIGHT=116
ASM_PLUS=117
ASM_MINUS=118
ASM_LESS_THAN=119
ASM_GREATER_THAN=120
ASM_MULTIPLY=121
ASM_DIVIDE=122
ASM_CURLY_BEGIN=123
ASM_CURLY_END=124
ASM_NUMBER=125
ASM_NUMFLOAT=126
ASM_BINFLOAT=127
ASM_DECFLOAT=128
ASM_HEXFLOAT=129
ASM_NUMINT=130
ASM_BININTEGER=131
ASM_DECINTEGER=132
ASM_HEXINTEGER=133
ASM_CHAR=134
ASM_MULTI_REL=135
ASM_MULTI_NAME=136
ASM_NAME=137
ASM_WS=138
ASM_COMMENT_LINE=139
ASM_COMMENT_BLOCK=140
';'=8
'..'=11
'?'=12
@ -171,35 +172,36 @@ ASM_COMMENT_BLOCK=139
'export'=51
'align'=52
'register'=53
'notregister'=54
'__zp'=55
'__mem'=56
'inline'=57
'volatile'=58
'interrupt'=59
'calling'=60
'if'=62
'else'=63
'while'=64
'do'=65
'for'=66
'switch'=67
'return'=68
'break'=69
'continue'=70
'asm'=71
'default'=72
'case'=73
'struct'=74
'enum'=75
'sizeof'=76
'typeid'=77
'kickasm'=78
'resource'=79
'uses'=80
'clobbers'=81
'bytes'=82
'cycles'=83
'!'=84
'.byte'=104
'#'=106
'__notregister'=54
'__address'=55
'__zp'=56
'__mem'=57
'inline'=58
'volatile'=59
'interrupt'=60
'calling'=61
'if'=63
'else'=64
'while'=65
'do'=66
'for'=67
'switch'=68
'return'=69
'break'=70
'continue'=71
'asm'=72
'default'=73
'case'=74
'struct'=75
'enum'=76
'sizeof'=77
'typeid'=78
'kickasm'=79
'resource'=80
'uses'=81
'clobbers'=82
'bytes'=83
'cycles'=84
'!'=85
'.byte'=105
'#'=107

View File

@ -101,7 +101,7 @@ directive
| ALIGN PAR_BEGIN NUMBER PAR_END #directiveAlign
| REGISTER ( PAR_BEGIN ( NAME ) PAR_END)? #directiveRegister
| NOTREGISTER #directiveNotRegister
| ( ZEROPAGE | MAINMEM ) ( PAR_BEGIN ( NUMBER ) PAR_END)? #directiveMemoryArea
| ADDRESS_ZEROPAGE | ADDRESS_MAINMEM | ( ADDRESS PAR_BEGIN ( NUMBER ) PAR_END) #directiveMemoryArea
| INLINE #directiveInline
| VOLATILE #directiveVolatile
| INTERRUPT ( PAR_BEGIN NAME PAR_END )? #directiveInterrupt

File diff suppressed because it is too large Load Diff

View File

@ -52,91 +52,92 @@ EXPORT=51
ALIGN=52
REGISTER=53
NOTREGISTER=54
ZEROPAGE=55
MAINMEM=56
INLINE=57
VOLATILE=58
INTERRUPT=59
CALLING=60
CALLINGCONVENTION=61
IF=62
ELSE=63
WHILE=64
DO=65
FOR=66
SWITCH=67
RETURN=68
BREAK=69
CONTINUE=70
ASM=71
DEFAULT=72
CASE=73
STRUCT=74
ENUM=75
SIZEOF=76
TYPEID=77
KICKASM=78
RESOURCE=79
USES=80
CLOBBERS=81
BYTES=82
CYCLES=83
LOGIC_NOT=84
SIGNEDNESS=85
SIMPLETYPE=86
BOOLEAN=87
KICKASM_BODY=88
STRING=89
CHAR=90
NUMBER=91
NUMFLOAT=92
BINFLOAT=93
DECFLOAT=94
HEXFLOAT=95
NUMINT=96
BININTEGER=97
DECINTEGER=98
HEXINTEGER=99
NAME=100
WS=101
COMMENT_LINE=102
COMMENT_BLOCK=103
ASM_BYTE=104
ASM_MNEMONIC=105
ASM_IMM=106
ASM_COLON=107
ASM_COMMA=108
ASM_PAR_BEGIN=109
ASM_PAR_END=110
ASM_BRACKET_BEGIN=111
ASM_BRACKET_END=112
ASM_DOT=113
ASM_SHIFT_LEFT=114
ASM_SHIFT_RIGHT=115
ASM_PLUS=116
ASM_MINUS=117
ASM_LESS_THAN=118
ASM_GREATER_THAN=119
ASM_MULTIPLY=120
ASM_DIVIDE=121
ASM_CURLY_BEGIN=122
ASM_CURLY_END=123
ASM_NUMBER=124
ASM_NUMFLOAT=125
ASM_BINFLOAT=126
ASM_DECFLOAT=127
ASM_HEXFLOAT=128
ASM_NUMINT=129
ASM_BININTEGER=130
ASM_DECINTEGER=131
ASM_HEXINTEGER=132
ASM_CHAR=133
ASM_MULTI_REL=134
ASM_MULTI_NAME=135
ASM_NAME=136
ASM_WS=137
ASM_COMMENT_LINE=138
ASM_COMMENT_BLOCK=139
ADDRESS=55
ADDRESS_ZEROPAGE=56
ADDRESS_MAINMEM=57
INLINE=58
VOLATILE=59
INTERRUPT=60
CALLING=61
CALLINGCONVENTION=62
IF=63
ELSE=64
WHILE=65
DO=66
FOR=67
SWITCH=68
RETURN=69
BREAK=70
CONTINUE=71
ASM=72
DEFAULT=73
CASE=74
STRUCT=75
ENUM=76
SIZEOF=77
TYPEID=78
KICKASM=79
RESOURCE=80
USES=81
CLOBBERS=82
BYTES=83
CYCLES=84
LOGIC_NOT=85
SIGNEDNESS=86
SIMPLETYPE=87
BOOLEAN=88
KICKASM_BODY=89
STRING=90
CHAR=91
NUMBER=92
NUMFLOAT=93
BINFLOAT=94
DECFLOAT=95
HEXFLOAT=96
NUMINT=97
BININTEGER=98
DECINTEGER=99
HEXINTEGER=100
NAME=101
WS=102
COMMENT_LINE=103
COMMENT_BLOCK=104
ASM_BYTE=105
ASM_MNEMONIC=106
ASM_IMM=107
ASM_COLON=108
ASM_COMMA=109
ASM_PAR_BEGIN=110
ASM_PAR_END=111
ASM_BRACKET_BEGIN=112
ASM_BRACKET_END=113
ASM_DOT=114
ASM_SHIFT_LEFT=115
ASM_SHIFT_RIGHT=116
ASM_PLUS=117
ASM_MINUS=118
ASM_LESS_THAN=119
ASM_GREATER_THAN=120
ASM_MULTIPLY=121
ASM_DIVIDE=122
ASM_CURLY_BEGIN=123
ASM_CURLY_END=124
ASM_NUMBER=125
ASM_NUMFLOAT=126
ASM_BINFLOAT=127
ASM_DECFLOAT=128
ASM_HEXFLOAT=129
ASM_NUMINT=130
ASM_BININTEGER=131
ASM_DECINTEGER=132
ASM_HEXINTEGER=133
ASM_CHAR=134
ASM_MULTI_REL=135
ASM_MULTI_NAME=136
ASM_NAME=137
ASM_WS=138
ASM_COMMENT_LINE=139
ASM_COMMENT_BLOCK=140
';'=8
'..'=11
'?'=12
@ -171,35 +172,36 @@ ASM_COMMENT_BLOCK=139
'export'=51
'align'=52
'register'=53
'notregister'=54
'__zp'=55
'__mem'=56
'inline'=57
'volatile'=58
'interrupt'=59
'calling'=60
'if'=62
'else'=63
'while'=64
'do'=65
'for'=66
'switch'=67
'return'=68
'break'=69
'continue'=70
'asm'=71
'default'=72
'case'=73
'struct'=74
'enum'=75
'sizeof'=76
'typeid'=77
'kickasm'=78
'resource'=79
'uses'=80
'clobbers'=81
'bytes'=82
'cycles'=83
'!'=84
'.byte'=104
'#'=106
'__notregister'=54
'__address'=55
'__zp'=56
'__mem'=57
'inline'=58
'volatile'=59
'interrupt'=60
'calling'=61
'if'=63
'else'=64
'while'=65
'do'=66
'for'=67
'switch'=68
'return'=69
'break'=70
'continue'=71
'asm'=72
'default'=73
'case'=74
'struct'=75
'enum'=76
'sizeof'=77
'typeid'=78
'kickasm'=79
'resource'=80
'uses'=81
'clobbers'=82
'bytes'=83
'cycles'=84
'!'=85
'.byte'=105
'#'=107

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;

View File

@ -839,17 +839,24 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
@Override
public Object visitDirectiveMemoryArea(KickCParser.DirectiveMemoryAreaContext ctx) {
SymbolVariable.MemoryArea mainMemory = ctx.ZEROPAGE() != null ? SymbolVariable.MemoryArea.ZEROPAGE_MEMORY : SymbolVariable.MemoryArea.MAIN_MEMORY;
Long address = null;
if(ctx.NUMBER() != null) {
try {
ConstantInteger memoryAddress = NumberParser.parseIntegerLiteral(ctx.NUMBER().getText());
address = memoryAddress.getInteger();
} catch(NumberFormatException e) {
throw new CompileError(e.getMessage(), new StatementSource(ctx));
if(ctx.ADDRESS_ZEROPAGE()!=null) {
return new DirectiveMemoryArea(SymbolVariable.MemoryArea.ZEROPAGE_MEMORY, null);
} else if(ctx.ADDRESS_MAINMEM()!=null) {
return new DirectiveMemoryArea(SymbolVariable.MemoryArea.MAIN_MEMORY, null);
} else if(ctx.ADDRESS()!=null && ctx.NUMBER()!=null) {
Long address = null;
if(ctx.NUMBER() != null) {
try {
ConstantInteger memoryAddress = NumberParser.parseIntegerLiteral(ctx.NUMBER().getText());
address = memoryAddress.getInteger();
SymbolVariable.MemoryArea memoryArea = (address<0x100)? SymbolVariable.MemoryArea.ZEROPAGE_MEMORY : SymbolVariable.MemoryArea.MAIN_MEMORY;
return new DirectiveMemoryArea(memoryArea, address);
} catch(NumberFormatException e) {
throw new CompileError(e.getMessage(), new StatementSource(ctx));
}
}
}
return new DirectiveMemoryArea(mainMemory, address);
return null;
}
@Override
@ -962,7 +969,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
/** true if the loop is a switch-statement. */
boolean isSwitch;
public Loop(Scope loopScope, boolean isSwitch) {
Loop(Scope loopScope, boolean isSwitch) {
this.loopScope = loopScope;
this.isSwitch = isSwitch;
}

View File

@ -1,6 +1,6 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
notregister __mem char idx;
__notregister __mem char idx;
const char* SCREEN = 0x0400;

View File

@ -1,7 +1,7 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a pointer to a memory variable
notregister __mem char idx;
__notregister __mem char idx;
char* idx_p = &idx;
const char* SCREEN = 0x0400;

View File

@ -3,7 +3,7 @@
const char* SCREEN = 0x0400;
notregister __mem char* cursor = SCREEN;
__notregister __mem char* cursor = SCREEN;
void main() {
for( char i: 0..24 ) {

View File

@ -6,7 +6,7 @@ struct foo {
char thing2;
};
notregister __mem struct foo bar = { 'a', 'b' };
__notregister __mem struct foo bar = { 'a', 'b' };
void main(void) {
struct foo* barp = &bar;

View File

@ -7,7 +7,7 @@ struct foo {
char[12] thing3;
};
notregister __mem struct foo bar = { 'a', 'b', "qwe" };
__notregister __mem struct foo bar = { 'a', 'b', "qwe" };
void main(void) {
struct foo* barp = &bar;

View File

@ -6,7 +6,7 @@ struct foo {
char thing2;
};
notregister __mem struct foo bar = { 'a', 'b' };
__notregister __mem struct foo bar = { 'a', 'b' };
void main(void) {
const char* SCREEN = 0x0400;

View File

@ -6,21 +6,21 @@ char i=0;
void main(void) {
char register __zp reg_zp_flex = '.';
char register __zp(0x10) reg_zp_abs = '.';
char register __address(0x10) reg_zp_abs = '.';
char register __mem reg_mem_flex = '.';
char register __mem(0x1000) reg_mem_abs = '.';
char notregister __zp notreg_zp_flex = '.';
char notregister __zp(0x10) notreg_zp_abs = '.';
char notregister __mem notreg_mem_flex = '.';
char notregister __mem(0x1000) notreg_mem_abs = '.';
char register __address(0x1000) reg_mem_abs = '.';
char __notregister __zp notreg_zp_flex = '.';
char __notregister __address(0x10) notreg_zp_abs = '.';
char __notregister __mem notreg_mem_flex = '.';
char __notregister __address(0x1000) notreg_mem_abs = '.';
char default_default = '.';
char register reg_default = '.';
char notregister notreg_default = '.';
char __notregister notreg_default = '.';
char __zp default_zp_flex = '.';
char __zp(0x10) default_zp_abs = '.';
char __address(0x10) default_zp_abs = '.';
char __mem default_mem_flex = '.';
char __mem(0x1000) default_mem_abs = '.';
char __address(0x1000) default_mem_abs = '.';
out(reg_zp_flex);
out(reg_zp_abs);

View File

@ -1,7 +1,7 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a zeropage notregister variable
notregister char idx;
__notregister char idx;
const char* SCREEN = 0x0400;

View File

@ -1,7 +1,7 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a fixed main memory address notregister variable
notregister __mem(0x1000) char idx;
__notregister __address(0x1000) char idx;
const char* SCREEN = 0x0400;

View File

@ -3,5 +3,5 @@
int* SCREEN = 0x0400;
void main() {
__zp(257) char i=0;
__address(257) char i=0;
}

View File

@ -7,7 +7,7 @@ void main() {
//print2(screen+80, "hello");
}
void print2(char* __zp(250) at, char* __zp(252) msg) {
void print2(char* __address(250) at, char* __address(252) msg) {
byte j=0;
for(byte i=0; msg[i]; i++) {
print_char(at, j, msg[i]);
@ -15,6 +15,6 @@ void print2(char* __zp(250) at, char* __zp(252) msg) {
}
}
void print_char(char* __zp(250) at, char register(X) idx, char register(A) ch) {
void print_char(char* __address(250) at, char register(X) idx, char register(A) ch) {
at[idx] = ch;
}

View File

@ -3,8 +3,8 @@
int* SCREEN = 0x0400;
void main() {
__zp(0x2) char i=0;
__zp(0x4) int j=0;
__address(0x2) char i=0;
__address(0x4) int j=0;
while(i<4) {
SCREEN[i++] = j++;
int k = (int)i*2;

View File

@ -0,0 +1,7 @@
// Test declaring a variable as register on a specific ZP address
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
main: {
rts
}

View File

@ -0,0 +1,17 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@return
main::@return: scope:[main] from main
[5] return
to:@return

View File

@ -0,0 +1,203 @@
Identified constant variable (signed word*) SCREEN
Identified constant variable (byte) main::i
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
(void()) main()
main: scope:[main] from @1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(label) main::@return
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@return
main::@return: scope:[main] from main
[5] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test declaring a variable as register on a specific ZP address
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
jmp __breturn
// main::@return
__breturn:
// [5] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope []
Uplifting [main] best 48 combination
Uplifting [] best 48 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test declaring a variable as register on a specific ZP address
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
jmp __breturn
// main::@return
__breturn:
// [5] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@return
FINAL ASSEMBLER
Score: 6
// File Comments
// Test declaring a variable as register on a specific ZP address
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// main::@return
// }
// [5] return
rts
}
// File Data

View File

@ -0,0 +1,6 @@
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@return