1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-09 08:54:40 +00:00
kickc/src/test/ref/struct-15.asm

40 lines
742 B
NASM

// Minimal struct with C-Standard behavior - copying
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const SIZEOF_STRUCT_POINT = 2
.const OFFSET_STRUCT_POINT_Y = 1
.label SCREEN = $400
main: {
.label point1 = 2
.label point2 = 4
// point1
ldy #SIZEOF_STRUCT_POINT
lda #0
!:
dey
sta point1,y
bne !-
// point1.x = 2
lda #2
sta.z point1
// point1.y = 3
lda #3
sta point1+OFFSET_STRUCT_POINT_Y
// point2 = point1
ldy #SIZEOF_STRUCT_POINT
!:
lda point1-1,y
sta point2-1,y
dey
bne !-
// SCREEN[0] = point2.x
lda.z point2
sta SCREEN
// SCREEN[1] = point2.y
lda point2+OFFSET_STRUCT_POINT_Y
sta SCREEN+1
// }
rts
}