2019-12-27 21:35:05 +00:00
|
|
|
// Minimal struct with C-Standard behavior - call parameter (not supported yet)
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
.label SCREEN = $400
|
2020-01-08 23:30:16 +00:00
|
|
|
.const SIZEOF_STRUCT_POINT = 2
|
2019-12-27 21:35:05 +00:00
|
|
|
.const OFFSET_STRUCT_POINT_Y = 1
|
|
|
|
main: {
|
|
|
|
.label point1 = 2
|
|
|
|
.label point2 = 4
|
2020-02-23 08:44:36 +00:00
|
|
|
// point1 = { 2, 3 }
|
2020-01-08 23:30:16 +00:00
|
|
|
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 }
|
2020-01-08 23:30:16 +00:00
|
|
|
ldy #SIZEOF_STRUCT_POINT
|
|
|
|
!:
|
|
|
|
lda __1-1,y
|
|
|
|
sta point2-1,y
|
|
|
|
dey
|
|
|
|
bne !-
|
2020-02-23 08:44:36 +00:00
|
|
|
// print(point1)
|
2019-12-27 21:35:05 +00:00
|
|
|
lda.z point1
|
|
|
|
ldx point1+OFFSET_STRUCT_POINT_Y
|
|
|
|
jsr print
|
2020-02-23 08:44:36 +00:00
|
|
|
// print(point2)
|
2019-12-27 21:35:05 +00:00
|
|
|
lda.z point2
|
|
|
|
ldx point2+OFFSET_STRUCT_POINT_Y
|
|
|
|
jsr print
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-12-27 21:35:05 +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
|
2019-12-27 21:35:05 +00:00
|
|
|
sta SCREEN
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[1] = p.y
|
2019-12-27 21:35:05 +00:00
|
|
|
stx SCREEN+1
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-12-27 21:35:05 +00:00
|
|
|
rts
|
|
|
|
}
|
2020-01-08 23:30:16 +00:00
|
|
|
__0: .byte 2, 3
|
|
|
|
__1: .byte 4, 5
|