1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-29 03:56:15 +00:00
kickc/src/test/ref/struct-22.asm

47 lines
901 B
NASM
Raw Normal View History

// Minimal struct with C-Standard behavior - call parameter (not supported yet)
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label SCREEN = $400
.const SIZEOF_STRUCT_POINT = 2
.const OFFSET_STRUCT_POINT_Y = 1
main: {
.label point1 = 2
.label point2 = 4
2020-02-23 08:44:36 +00:00
// point1 = { 2, 3 }
ldy #SIZEOF_STRUCT_POINT
!:
lda __0-1,y
sta point1-1,y
dey
bne !-
2020-02-23 08:44:36 +00:00
// point2 = { 4, 5 }
ldy #SIZEOF_STRUCT_POINT
!:
lda __1-1,y
sta point2-1,y
dey
bne !-
2020-02-23 08:44:36 +00:00
// print(point1)
lda.z point1
ldx point1+OFFSET_STRUCT_POINT_Y
jsr print
2020-02-23 08:44:36 +00:00
// print(point2)
lda.z point2
ldx point2+OFFSET_STRUCT_POINT_Y
jsr print
2020-02-23 08:44:36 +00:00
// }
rts
}
// print(byte register(A) p_x, byte register(X) p_y)
print: {
2020-02-23 08:44:36 +00:00
// SCREEN[0] = p.x
sta SCREEN
2020-02-23 08:44:36 +00:00
// SCREEN[1] = p.y
stx SCREEN+1
2020-02-23 08:44:36 +00:00
// }
rts
}
__0: .byte 2, 3
__1: .byte 4, 5