mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-07 07:29:49 +00:00
Working on structs
This commit is contained in:
parent
9c682e37fe
commit
837104f4fd
@ -1,2 +0,0 @@
|
||||
lda {z1}+0
|
||||
sta {c1}
|
@ -1,2 +0,0 @@
|
||||
lda {z1}+1
|
||||
sta {c1}
|
4
src/main/fragment/vssz1=vssz2.asm
Normal file
4
src/main/fragment/vssz1=vssz2.asm
Normal file
@ -0,0 +1,4 @@
|
||||
lda {z2}
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
sta {z1}+1
|
@ -1,2 +0,0 @@
|
||||
lda #{c1}
|
||||
sta {z1}+0
|
@ -1,2 +0,0 @@
|
||||
lda #{c1}
|
||||
sta {z1}+1
|
@ -497,6 +497,9 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor<Object> {
|
||||
// Add comments to constant
|
||||
lValue.setComments(ensureUnusedComments(comments));
|
||||
}
|
||||
if(type instanceof SymbolTypeStruct) {
|
||||
lValue.setDeclaredVolatile(true);
|
||||
}
|
||||
KickCParser.ExprContext initializer = ctx.expr();
|
||||
if(declVarStructMember) {
|
||||
if(initializer != null) {
|
||||
|
@ -32,6 +32,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStruct2() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStruct1() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-1");
|
||||
|
20
src/test/kc/struct-2.kc
Normal file
20
src/test/kc/struct-2.kc
Normal file
@ -0,0 +1,20 @@
|
||||
// Minimal struct - different instances and copying
|
||||
|
||||
struct Point {
|
||||
byte x;
|
||||
byte y;
|
||||
};
|
||||
|
||||
struct Point point1, point2;
|
||||
|
||||
void main() {
|
||||
point1.x = 2;
|
||||
point1.y = 3;
|
||||
point2 = point1;
|
||||
point2.x = 4;
|
||||
const byte* SCREEN = 0x0400;
|
||||
SCREEN[0] = point1.x;
|
||||
SCREEN[1] = point1.y;
|
||||
SCREEN[2] = point2.x;
|
||||
SCREEN[3] = point2.y;
|
||||
}
|
36
src/test/ref/struct-2.asm
Normal file
36
src/test/ref/struct-2.asm
Normal file
@ -0,0 +1,36 @@
|
||||
// Minimal struct - different instances and copying
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(bbegin)
|
||||
.pc = $80d "Program"
|
||||
.label point1 = 2
|
||||
.label point2 = 4
|
||||
bbegin:
|
||||
lda #0
|
||||
sta point1
|
||||
sta point1+1
|
||||
sta point2
|
||||
sta point2+1
|
||||
jsr main
|
||||
rts
|
||||
main: {
|
||||
.label SCREEN = $400
|
||||
lda #2
|
||||
sta point1+0
|
||||
lda #3
|
||||
sta point1+1
|
||||
lda point1
|
||||
sta point2
|
||||
lda point1+1
|
||||
sta point2+1
|
||||
lda #4
|
||||
sta point2+0
|
||||
lda point1+0
|
||||
sta SCREEN
|
||||
lda point1+1
|
||||
sta SCREEN+1
|
||||
lda point2+0
|
||||
sta SCREEN+2
|
||||
lda point2+1
|
||||
sta SCREEN+3
|
||||
rts
|
||||
}
|
Loading…
Reference in New Issue
Block a user