mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-27 09:31:18 +00:00
- Added banking signature to procedures in the comments of the assembler output file.
- Update test cases and reference data. - Cleaned old test cases for stack calls.
This commit is contained in:
parent
82a6c56e0a
commit
02d9eaf081
@ -103,7 +103,7 @@ package dk.camelot64.kickc.model;
|
||||
* The KickC compiler contains several test cases and examples which demonstrate the usage of the banking system.
|
||||
*
|
||||
*/
|
||||
public class Bank {
|
||||
public class Bank extends Object {
|
||||
|
||||
private final String bankArea; // The bank method to apply.
|
||||
private Long bank; // The bank number.
|
||||
@ -132,4 +132,11 @@ public class Bank {
|
||||
public void setBank(Long bank) {
|
||||
this.bank = bank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "banked : " +
|
||||
"bank area='" + bankArea + '\'' +
|
||||
", bank=" + bank;
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +219,8 @@ public class Pass4CodeGeneration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a comment that describes the procedure signature and parameter transfer
|
||||
* Generate a comment that describes the procedure signature and parameter transfer.
|
||||
* We have added here also the banking information.
|
||||
*
|
||||
* @param asm The assembler program being generated
|
||||
* @param procedure The procedure
|
||||
@ -240,6 +241,13 @@ public class Pass4CodeGeneration {
|
||||
if (i > 0) {
|
||||
asm.addComment(signature.toString(), false);
|
||||
}
|
||||
// Banking information of the procedure.
|
||||
Bank bank = procedure.getBankLocation();
|
||||
if(bank != null) {
|
||||
StringBuilder signatureBank = new StringBuilder();
|
||||
signatureBank.append(" " + bank.toString()); // This procedure is in a bank and in a banking area.
|
||||
asm.addComment(signatureBank.toString(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,16 +0,0 @@
|
||||
// Test a procedure with calling convention stack
|
||||
|
||||
#pragma code_seg(stage)
|
||||
#pragma link("procedure-callingconvention-stack-bank.ld")
|
||||
#pragma target(cx16)
|
||||
|
||||
char* const SCREEN = (char*)0x0400;
|
||||
|
||||
void main(void) {
|
||||
SCREEN[0] = plus('0', 7);
|
||||
}
|
||||
|
||||
#pragma code_seg(stage)
|
||||
char __bank(ram, 2) __stackcall plus(char a, char b) {
|
||||
return a+b;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
// Test a procedure with calling convention stack
|
||||
|
||||
#pragma code_seg(stage)
|
||||
#pragma link("procedure-callingconvention-stack-bank.ld")
|
||||
#pragma target(cx16)
|
||||
|
||||
char* const SCREEN = (char*)0x0400;
|
||||
|
||||
void main(void) {
|
||||
SCREEN[0] = plus('0', 7);
|
||||
}
|
||||
|
||||
#pragma calling(__stackcall)
|
||||
#pragma code_seg(stage)
|
||||
|
||||
char __bank(ram,20) plus(char a, char b) {
|
||||
return a+b;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
// Test a procedure with calling convention stack
|
||||
// A slightly more complex call
|
||||
|
||||
#pragma code_seg(stage)
|
||||
#pragma link("procedure-callingconvention-stack-bank.ld")
|
||||
#pragma target(cx16)
|
||||
|
||||
char* const SCREEN = (char*)0x0400;
|
||||
|
||||
char i = 0;
|
||||
|
||||
void main(void) {
|
||||
for(char a:0..1) {
|
||||
char v = a+1;
|
||||
char w = plus('0', v);
|
||||
SCREEN[i] = w+a;
|
||||
}
|
||||
}
|
||||
|
||||
// this should give a pragma error during compile, as test is not declared yet.
|
||||
char __bank(ram, 20) __stackcall plus(char a, char b) {
|
||||
i++;
|
||||
return a+b;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
// Test a procedure with calling convention stack
|
||||
// Illustrates live range problem with function variable printother::i and global variable val
|
||||
|
||||
#pragma calling(__stackcall)
|
||||
|
||||
#pragma code_seg(stage)
|
||||
#pragma link("procedure-callingconvention-stack-bank.ld")
|
||||
#pragma target(cx16)
|
||||
|
||||
char* const SCREEN = (char*)0x0400;
|
||||
|
||||
char val = 0;
|
||||
|
||||
void main(void) {
|
||||
for(char i:0..5) {
|
||||
pval();
|
||||
printother();
|
||||
ival();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(stage)
|
||||
|
||||
void __bank(ram, 20) pval() {
|
||||
printval();
|
||||
}
|
||||
|
||||
#pragma code_seg(platform)
|
||||
|
||||
void __bank(ram, 21) ival() {
|
||||
incval();
|
||||
}
|
||||
|
||||
#pragma code_seg(stage)
|
||||
|
||||
void __bank(ram, 20) printval() {
|
||||
SCREEN[0] = val;
|
||||
}
|
||||
|
||||
|
||||
#pragma code_seg(platform)
|
||||
|
||||
void __bank(ram, 21) incval() {
|
||||
val++;
|
||||
}
|
||||
|
||||
#pragma nobank
|
||||
#pragma code_seg(Code)
|
||||
|
||||
void printother() {
|
||||
for(char i:0..5) {
|
||||
(SCREEN+40)[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
// Test a procedure with calling convention stack
|
||||
// Returning and passing struct values
|
||||
|
||||
#pragma calling(__stackcall)
|
||||
#pragma struct_model(classic)
|
||||
|
||||
#pragma code_seg(stage)
|
||||
#pragma link("procedure-callingconvention-stack-bank.ld")
|
||||
#pragma target(cx16)
|
||||
|
||||
char* const SCREEN = (char*)0x0400;
|
||||
char idx = 0;
|
||||
|
||||
struct Point {
|
||||
char x;
|
||||
char y;
|
||||
};
|
||||
|
||||
void main(void) {
|
||||
for(char i=0;i<5;i++) {
|
||||
struct Point p = get(i);
|
||||
print(p);
|
||||
}
|
||||
}
|
||||
|
||||
struct Point __bank(ram,1) get(char i) {
|
||||
struct Point p = { i, i/2 };
|
||||
return p;
|
||||
}
|
||||
|
||||
void __bank(ram,2) print(struct Point p) {
|
||||
SCREEN[idx++] = p.x;
|
||||
SCREEN[idx++] = p.y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
// Test a procedure with calling convention stack
|
||||
// Recursion that works (no local variables)
|
||||
|
||||
#pragma code_seg(stage)
|
||||
#pragma link("procedure-callingconvention-stack-bank.ld")
|
||||
#pragma platform(cx16)
|
||||
|
||||
char* const SCREEN = (char*)0x0400;
|
||||
|
||||
void main(void) {
|
||||
*SCREEN = pow2(6);
|
||||
}
|
||||
|
||||
char __stackcall __bank(ram,1) pow2(char n) {
|
||||
if (n == 0)
|
||||
return 1;
|
||||
else {
|
||||
char c = pow2(n-1);
|
||||
return c+c;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
.segmentdef Program [segments="Basic, Code, Data, stage, platform"]
|
||||
.segmentdef Basic [start=$0801]
|
||||
.segmentdef Code [start=%P]
|
||||
.segmentdef Data [startAfter="Code"]
|
||||
.segmentdef stage [start=$0400, min=$0400, max=$07FF, align=$100]
|
||||
.segmentdef platform [start=$C000, min=$C000, max=$C7FF, align=$100]
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.const a = '0'
|
||||
.const b = 7
|
||||
|
@ -229,6 +229,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.const a = '0'
|
||||
.const b = 7
|
||||
@ -338,6 +339,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.const a = '0'
|
||||
.const b = 7
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.const a = '0'
|
||||
.const b = 7
|
||||
|
@ -229,6 +229,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.const a = '0'
|
||||
.const b = 7
|
||||
@ -338,6 +339,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.const a = '0'
|
||||
.const b = 7
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
|
@ -298,6 +298,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -428,6 +429,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
|
@ -298,6 +298,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -428,6 +429,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -66,6 +67,7 @@ plus: {
|
||||
rts
|
||||
}
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
rts
|
||||
|
@ -298,6 +298,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -313,6 +314,7 @@ plus: {
|
||||
}
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
jmp __breturn
|
||||
@ -427,6 +429,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -441,6 +444,7 @@ plus: {
|
||||
}
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
// min::@return
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -66,6 +67,7 @@ plus: {
|
||||
rts
|
||||
}
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
rts
|
||||
|
@ -298,6 +298,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -313,6 +314,7 @@ plus: {
|
||||
}
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
jmp __breturn
|
||||
@ -427,6 +429,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -441,6 +444,7 @@ plus: {
|
||||
}
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
// min::@return
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -70,6 +71,7 @@ plus: {
|
||||
}
|
||||
.segment RAM_Bank2
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=2
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
rts
|
||||
|
@ -298,6 +298,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -317,6 +318,7 @@ plus: {
|
||||
.segment RAM_Bank2
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=2
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
jmp __breturn
|
||||
@ -431,6 +433,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -449,6 +452,7 @@ plus: {
|
||||
.segment RAM_Bank2
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=2
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
// min::@return
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -70,6 +71,7 @@ plus: {
|
||||
}
|
||||
.segment RAM_Bank2
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=2
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
rts
|
||||
|
@ -298,6 +298,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -317,6 +318,7 @@ plus: {
|
||||
.segment RAM_Bank2
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=2
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
jmp __breturn
|
||||
@ -431,6 +433,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -449,6 +452,7 @@ plus: {
|
||||
.segment RAM_Bank2
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=2
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
// min::@return
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -72,6 +73,7 @@ plus: {
|
||||
}
|
||||
.segment ROM_Bank1
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_rom', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
rts
|
||||
|
@ -299,6 +299,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -320,6 +321,7 @@ plus: {
|
||||
.segment ROM_Bank1
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_rom', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
jmp __breturn
|
||||
@ -434,6 +436,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -454,6 +457,7 @@ plus: {
|
||||
.segment ROM_Bank1
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_rom', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
// min::@return
|
||||
|
@ -57,6 +57,7 @@ main: {
|
||||
}
|
||||
.segment RAM_Bank1
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -72,6 +73,7 @@ plus: {
|
||||
}
|
||||
.segment ROM_Bank1
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_rom', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
rts
|
||||
|
@ -299,6 +299,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -320,6 +321,7 @@ plus: {
|
||||
.segment ROM_Bank1
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_rom', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
jmp __breturn
|
||||
@ -434,6 +436,7 @@ main: {
|
||||
.segment RAM_Bank1
|
||||
// plus
|
||||
// char plus(char a, char b)
|
||||
// banked : bank area='cx16_ram', bank=1
|
||||
plus: {
|
||||
.label a = '0'
|
||||
.label b = 7
|
||||
@ -454,6 +457,7 @@ plus: {
|
||||
.segment ROM_Bank1
|
||||
// min
|
||||
// char min(char a, char b)
|
||||
// banked : bank area='cx16_rom', bank=1
|
||||
min: {
|
||||
.label return = plus.a+plus.b
|
||||
// min::@return
|
||||
|
Loading…
Reference in New Issue
Block a user