mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 08:32:39 +00:00
Added missing test data.
This commit is contained in:
parent
2e934a7a30
commit
f32f44cd92
178
src/test/ref/procedure-callingconvention-stack-11.asm
Normal file
178
src/test/ref/procedure-callingconvention-stack-11.asm
Normal file
@ -0,0 +1,178 @@
|
||||
// Test a procedure with calling convention stack
|
||||
// Returning and passing struct of struct values
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(__bbegin)
|
||||
.pc = $80d "Program"
|
||||
.label SCREEN = $400
|
||||
.const OFFSET_STRUCT_POINT_Y = 1
|
||||
.const OFFSET_STRUCT_VECTOR_P2 = 2
|
||||
.const STACK_BASE = $103
|
||||
.label idx = 2
|
||||
__bbegin:
|
||||
// idx = 0
|
||||
lda #0
|
||||
sta.z idx
|
||||
jsr main
|
||||
rts
|
||||
// print(byte register(Y) v_p1_x, byte zp(3) v_p1_y, byte zp(4) v_p2_x, byte register(X) v_p2_y)
|
||||
print: {
|
||||
.const OFFSET_STACK_V_P1_X = 3
|
||||
.const OFFSET_STACK_V_P1_Y = 2
|
||||
.const OFFSET_STACK_V_P2_X = 1
|
||||
.const OFFSET_STACK_V_P2_Y = 0
|
||||
.label v_p1_y = 3
|
||||
.label v_p2_x = 4
|
||||
// }
|
||||
tsx
|
||||
lda STACK_BASE+OFFSET_STACK_V_P1_X,x
|
||||
tay
|
||||
tsx
|
||||
lda STACK_BASE+OFFSET_STACK_V_P1_Y,x
|
||||
sta.z v_p1_y
|
||||
tsx
|
||||
lda STACK_BASE+OFFSET_STACK_V_P2_X,x
|
||||
sta.z v_p2_x
|
||||
tsx
|
||||
lda STACK_BASE+OFFSET_STACK_V_P2_Y,x
|
||||
tax
|
||||
// SCREEN[idx++] = v.p1.x
|
||||
tya
|
||||
ldy.z idx
|
||||
sta SCREEN,y
|
||||
// SCREEN[idx++] = v.p1.x;
|
||||
inc.z idx
|
||||
// SCREEN[idx++] = v.p1.y
|
||||
lda.z v_p1_y
|
||||
ldy.z idx
|
||||
sta SCREEN,y
|
||||
// SCREEN[idx++] = v.p1.y;
|
||||
inc.z idx
|
||||
// SCREEN[idx++] = v.p2.x
|
||||
lda.z v_p2_x
|
||||
ldy.z idx
|
||||
sta SCREEN,y
|
||||
// SCREEN[idx++] = v.p2.x;
|
||||
inc.z idx
|
||||
// SCREEN[idx++] = v.p2.y
|
||||
ldy.z idx
|
||||
txa
|
||||
sta SCREEN,y
|
||||
// SCREEN[idx++] = v.p2.y;
|
||||
inc.z idx
|
||||
// SCREEN[idx++] = ' '
|
||||
lda #' '
|
||||
ldy.z idx
|
||||
sta SCREEN,y
|
||||
// SCREEN[idx++] = ' ';
|
||||
inc.z idx
|
||||
// }
|
||||
rts
|
||||
}
|
||||
// get(byte register(Y) i)
|
||||
get: {
|
||||
.const OFFSET_STACK_I = 0
|
||||
.label __0 = 3
|
||||
.label __2 = 4
|
||||
.label v = $10
|
||||
.label return_p2_x = 6
|
||||
.label return_p2_y = 7
|
||||
tsx
|
||||
lda STACK_BASE+OFFSET_STACK_I,x
|
||||
tay
|
||||
// i/2
|
||||
tya
|
||||
lsr
|
||||
sta.z __0
|
||||
// i+1
|
||||
tya
|
||||
tax
|
||||
inx
|
||||
// i*2
|
||||
tya
|
||||
asl
|
||||
sta.z __2
|
||||
// v = { {i, i/2}, {i+1, i*2} }
|
||||
sty.z v
|
||||
lda.z __0
|
||||
sta v+OFFSET_STRUCT_POINT_Y
|
||||
stx v+OFFSET_STRUCT_VECTOR_P2
|
||||
lda.z __2
|
||||
sta v+OFFSET_STRUCT_VECTOR_P2+OFFSET_STRUCT_POINT_Y
|
||||
// return v;
|
||||
ldx.z v
|
||||
ldy v+OFFSET_STRUCT_POINT_Y
|
||||
lda v+OFFSET_STRUCT_VECTOR_P2
|
||||
sta.z return_p2_x
|
||||
lda v+OFFSET_STRUCT_VECTOR_P2+OFFSET_STRUCT_POINT_Y
|
||||
sta.z return_p2_y
|
||||
// }
|
||||
txa
|
||||
tsx
|
||||
sta STACK_BASE+0,x
|
||||
tya
|
||||
tsx
|
||||
sta STACK_BASE+OFFSET_STRUCT_POINT_Y,x
|
||||
lda.z return_p2_x
|
||||
tsx
|
||||
sta STACK_BASE+OFFSET_STRUCT_VECTOR_P2,x
|
||||
lda.z return_p2_y
|
||||
tsx
|
||||
sta STACK_BASE+OFFSET_STRUCT_VECTOR_P2+OFFSET_STRUCT_POINT_Y,x
|
||||
rts
|
||||
}
|
||||
main: {
|
||||
.label i = 5
|
||||
.label v = $c
|
||||
.label __1_p2_x = 6
|
||||
.label __1_p2_y = 7
|
||||
// i=0
|
||||
lda #0
|
||||
sta.z i
|
||||
__b1:
|
||||
// for(char i=0;i<5;i++)
|
||||
lda.z i
|
||||
cmp #5
|
||||
bcc __b2
|
||||
// }
|
||||
rts
|
||||
__b2:
|
||||
// get(i)
|
||||
lda.z i
|
||||
pha
|
||||
pha
|
||||
pha
|
||||
pha
|
||||
jsr get
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
pla
|
||||
sta.z __1_p2_x
|
||||
pla
|
||||
sta.z __1_p2_y
|
||||
// v = get(i)
|
||||
sty.z v
|
||||
stx v+OFFSET_STRUCT_POINT_Y
|
||||
lda.z __1_p2_x
|
||||
sta v+OFFSET_STRUCT_VECTOR_P2
|
||||
lda.z __1_p2_y
|
||||
sta v+OFFSET_STRUCT_VECTOR_P2+OFFSET_STRUCT_POINT_Y
|
||||
// print(v)
|
||||
tya
|
||||
pha
|
||||
txa
|
||||
pha
|
||||
lda v+OFFSET_STRUCT_VECTOR_P2
|
||||
pha
|
||||
lda v+OFFSET_STRUCT_VECTOR_P2+OFFSET_STRUCT_POINT_Y
|
||||
pha
|
||||
jsr print
|
||||
tsx
|
||||
txa
|
||||
axs #-4
|
||||
txs
|
||||
// for(char i=0;i<5;i++)
|
||||
inc.z i
|
||||
jmp __b1
|
||||
}
|
84
src/test/ref/procedure-callingconvention-stack-11.cfg
Normal file
84
src/test/ref/procedure-callingconvention-stack-11.cfg
Normal file
@ -0,0 +1,84 @@
|
||||
@begin: scope:[] from
|
||||
[0] (byte) idx ← (byte) 0
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] callexecute main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
|
||||
__stackcall (void()) print((byte) print::v_p1_x , (byte) print::v_p1_y , (byte) print::v_p2_x , (byte) print::v_p2_y)
|
||||
print: scope:[print] from
|
||||
[4] (byte) print::v_p1_x#0 ← stackidx(byte,(const byte) print::OFFSET_STACK_V_P1_X)
|
||||
[5] (byte) print::v_p1_y#0 ← stackidx(byte,(const byte) print::OFFSET_STACK_V_P1_Y)
|
||||
[6] (byte) print::v_p2_x#0 ← stackidx(byte,(const byte) print::OFFSET_STACK_V_P2_X)
|
||||
[7] (byte) print::v_p2_y#0 ← stackidx(byte,(const byte) print::OFFSET_STACK_V_P2_Y)
|
||||
[8] *((const byte*) SCREEN + (byte) idx) ← (byte) print::v_p1_x#0
|
||||
[9] (byte) idx ← ++ (byte) idx
|
||||
[10] *((const byte*) SCREEN + (byte) idx) ← (byte) print::v_p1_y#0
|
||||
[11] (byte) idx ← ++ (byte) idx
|
||||
[12] *((const byte*) SCREEN + (byte) idx) ← (byte) print::v_p2_x#0
|
||||
[13] (byte) idx ← ++ (byte) idx
|
||||
[14] *((const byte*) SCREEN + (byte) idx) ← (byte) print::v_p2_y#0
|
||||
[15] (byte) idx ← ++ (byte) idx
|
||||
[16] *((const byte*) SCREEN + (byte) idx) ← (byte) ' '
|
||||
[17] (byte) idx ← ++ (byte) idx
|
||||
to:print::@return
|
||||
print::@return: scope:[print] from print
|
||||
[18] return
|
||||
to:@return
|
||||
|
||||
__stackcall (struct Vector()) get((byte) get::i)
|
||||
get: scope:[get] from
|
||||
[19] (byte) get::i#0 ← stackidx(byte,(const byte) get::OFFSET_STACK_I)
|
||||
[20] (byte~) get::$0 ← (byte) get::i#0 >> (byte) 1
|
||||
[21] (byte~) get::$1 ← (byte) get::i#0 + (byte) 1
|
||||
[22] (byte~) get::$2 ← (byte) get::i#0 << (byte) 1
|
||||
[23] *((byte*)(struct Point*)&(struct Vector) get::v) ← (byte) get::i#0
|
||||
[24] *((byte*)(struct Point*)&(struct Vector) get::v+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) get::$0
|
||||
[25] *((byte*)(struct Point*)&(struct Vector) get::v+(const byte) OFFSET_STRUCT_VECTOR_P2) ← (byte~) get::$1
|
||||
[26] *((byte*)(struct Point*)&(struct Vector) get::v+(const byte) OFFSET_STRUCT_VECTOR_P2+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) get::$2
|
||||
[27] (byte) get::return_p1_x#0 ← *((byte*)(struct Point*)&(struct Vector) get::v)
|
||||
[28] (byte) get::return_p1_y#0 ← *((byte*)(struct Point*)&(struct Vector) get::v+(const byte) OFFSET_STRUCT_POINT_Y)
|
||||
[29] (byte) get::return_p2_x#0 ← *((byte*)(struct Point*)&(struct Vector) get::v+(const byte) OFFSET_STRUCT_VECTOR_P2)
|
||||
[30] (byte) get::return_p2_y#0 ← *((byte*)(struct Point*)&(struct Vector) get::v+(const byte) OFFSET_STRUCT_VECTOR_P2+(const byte) OFFSET_STRUCT_POINT_Y)
|
||||
to:get::@return
|
||||
get::@return: scope:[get] from get
|
||||
[31] stackidx(byte,(byte) 0) ← (byte) get::return_p1_x#0
|
||||
[32] stackidx(byte,(const byte) OFFSET_STRUCT_POINT_Y) ← (byte) get::return_p1_y#0
|
||||
[33] stackidx(byte,(const byte) OFFSET_STRUCT_VECTOR_P2) ← (byte) get::return_p2_x#0
|
||||
[34] stackidx(byte,(const byte) OFFSET_STRUCT_VECTOR_P2+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte) get::return_p2_y#0
|
||||
[35] return
|
||||
to:@return
|
||||
|
||||
__stackcall (void()) main()
|
||||
main: scope:[main] from
|
||||
[36] (byte) main::i ← (byte) 0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[37] if((byte) main::i<(byte) 5) goto main::@2
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[38] return
|
||||
to:@return
|
||||
main::@2: scope:[main] from main::@1
|
||||
[39] stackpush(byte) ← (byte) main::i
|
||||
sideeffect stackpushbytes((number) 3)
|
||||
[41] callexecute get
|
||||
[42] (byte~) main::$1_p1_x ← stackpull(byte)
|
||||
[43] (byte~) main::$1_p1_y ← stackpull(byte)
|
||||
[44] (byte~) main::$1_p2_x ← stackpull(byte)
|
||||
[45] (byte~) main::$1_p2_y ← stackpull(byte)
|
||||
[46] *((byte*)(struct Point*)&(struct Vector) main::v) ← (byte~) main::$1_p1_x
|
||||
[47] *((byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$1_p1_y
|
||||
[48] *((byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P2) ← (byte~) main::$1_p2_x
|
||||
[49] *((byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P2+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$1_p2_y
|
||||
[50] stackpush(byte) ← *((byte*)(struct Point*)&(struct Vector) main::v)
|
||||
[51] stackpush(byte) ← *((byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_POINT_Y)
|
||||
[52] stackpush(byte) ← *((byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P2)
|
||||
[53] stackpush(byte) ← *((byte*)(struct Point*)&(struct Vector) main::v+(const byte) OFFSET_STRUCT_VECTOR_P2+(const byte) OFFSET_STRUCT_POINT_Y)
|
||||
[54] callexecute print
|
||||
sideeffect stackpullbytes((number) 4)
|
||||
[56] (byte) main::i ← ++ (byte) main::i
|
||||
to:main::@1
|
1537
src/test/ref/procedure-callingconvention-stack-11.log
Normal file
1537
src/test/ref/procedure-callingconvention-stack-11.log
Normal file
File diff suppressed because it is too large
Load Diff
77
src/test/ref/procedure-callingconvention-stack-11.sym
Normal file
77
src/test/ref/procedure-callingconvention-stack-11.sym
Normal file
@ -0,0 +1,77 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) OFFSET_STRUCT_POINT_Y = (byte) 1
|
||||
(const byte) OFFSET_STRUCT_VECTOR_P2 = (byte) 2
|
||||
(byte) Point::x loadstore
|
||||
(byte) Point::y loadstore
|
||||
(const byte*) SCREEN = (byte*) 1024
|
||||
(const word) STACK_BASE = (word) $103
|
||||
(struct Point) Vector::p1 loadstore zp[2]:8
|
||||
(struct Point) Vector::p2 loadstore zp[2]:10
|
||||
__stackcall (struct Vector()) get((byte) get::i)
|
||||
(byte~) get::$0 zp[1]:3 1.0
|
||||
(byte~) get::$1 reg byte x 1.0
|
||||
(byte~) get::$2 zp[1]:4 1.0
|
||||
(label) get::@return
|
||||
(const byte) get::OFFSET_STACK_I = (byte) 0
|
||||
(byte) get::i
|
||||
(byte) get::i#0 reg byte y 2.5
|
||||
(struct Vector) get::return
|
||||
(struct Point) get::return_p1
|
||||
(byte) get::return_p1_x
|
||||
(byte) get::return_p1_x#0 reg byte x 1.0
|
||||
(byte) get::return_p1_y
|
||||
(byte) get::return_p1_y#0 reg byte y 1.0
|
||||
(struct Point) get::return_p2
|
||||
(byte) get::return_p2_x
|
||||
(byte) get::return_p2_x#0 return_p2_x zp[1]:6 1.0
|
||||
(byte) get::return_p2_y
|
||||
(byte) get::return_p2_y#0 return_p2_y zp[1]:7 1.0
|
||||
(struct Vector) get::v loadstore zp[4]:16
|
||||
(byte) idx loadstore zp[1]:2 0.8648648648648649
|
||||
__stackcall (void()) main()
|
||||
(byte~) main::$1_p1_x reg byte y 5.5
|
||||
(byte~) main::$1_p1_y reg byte x 5.5
|
||||
(byte~) main::$1_p2_x zp[1]:6 5.5
|
||||
(byte~) main::$1_p2_y zp[1]:7 5.5
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
(byte) main::i loadstore zp[1]:5 2.3000000000000003
|
||||
(struct Vector) main::v loadstore zp[4]:12
|
||||
__stackcall (void()) print((byte) print::v_p1_x , (byte) print::v_p1_y , (byte) print::v_p2_x , (byte) print::v_p2_y)
|
||||
(label) print::@return
|
||||
(const byte) print::OFFSET_STACK_V_P1_X = (byte) 3
|
||||
(const byte) print::OFFSET_STACK_V_P1_Y = (byte) 2
|
||||
(const byte) print::OFFSET_STACK_V_P2_X = (byte) 1
|
||||
(const byte) print::OFFSET_STACK_V_P2_Y = (byte) 0
|
||||
(struct Point) print::v_p1
|
||||
(byte) print::v_p1_x
|
||||
(byte) print::v_p1_x#0 reg byte y 1.0
|
||||
(byte) print::v_p1_y
|
||||
(byte) print::v_p1_y#0 v_p1_y zp[1]:3 0.8
|
||||
(struct Point) print::v_p2
|
||||
(byte) print::v_p2_x
|
||||
(byte) print::v_p2_x#0 v_p2_x zp[1]:4 0.6666666666666666
|
||||
(byte) print::v_p2_y
|
||||
(byte) print::v_p2_y#0 reg byte x 0.5714285714285714
|
||||
|
||||
zp[1]:2 [ idx ]
|
||||
reg byte y [ print::v_p1_x#0 ]
|
||||
reg byte x [ print::v_p2_y#0 ]
|
||||
reg byte y [ get::i#0 ]
|
||||
zp[1]:3 [ get::$0 print::v_p1_y#0 ]
|
||||
reg byte x [ get::$1 ]
|
||||
zp[1]:4 [ get::$2 print::v_p2_x#0 ]
|
||||
reg byte x [ get::return_p1_x#0 ]
|
||||
reg byte y [ get::return_p1_y#0 ]
|
||||
zp[1]:5 [ main::i ]
|
||||
reg byte y [ main::$1_p1_x ]
|
||||
reg byte x [ main::$1_p1_y ]
|
||||
zp[1]:6 [ main::$1_p2_x get::return_p2_x#0 ]
|
||||
zp[1]:7 [ main::$1_p2_y get::return_p2_y#0 ]
|
||||
zp[2]:8 [ Vector::p1 ]
|
||||
zp[2]:10 [ Vector::p2 ]
|
||||
zp[4]:12 [ main::v ]
|
||||
zp[4]:16 [ get::v ]
|
Loading…
Reference in New Issue
Block a user