2019-09-14 09:21:29 +00:00
|
|
|
// Test adding integer index to a pointer that is a literal string
|
|
|
|
// https://gitlab.com/camelot/kickc/issues/315
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="string-pointer-problem.prg", type="prg", segments="Program"]
|
|
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
|
|
.segmentdef Basic [start=$0801]
|
|
|
|
.segmentdef Code [start=$80d]
|
|
|
|
.segmentdef Data [startAfter="Code"]
|
|
|
|
.segment Basic
|
2019-09-14 09:21:29 +00:00
|
|
|
:BasicUpstart(main)
|
|
|
|
.label process_name = $400
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-09-14 09:21:29 +00:00
|
|
|
main: {
|
2020-02-23 08:44:36 +00:00
|
|
|
// set_process_name("keyboard")
|
2019-09-14 09:21:29 +00:00
|
|
|
jsr set_process_name
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-09-14 09:21:29 +00:00
|
|
|
rts
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Data
|
2019-09-14 09:21:29 +00:00
|
|
|
name: .text "keyboard"
|
|
|
|
.byte 0
|
|
|
|
}
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-09-14 09:21:29 +00:00
|
|
|
set_process_name: {
|
|
|
|
.label j = 2
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __1 = 4
|
|
|
|
.label __2 = 6
|
2019-09-14 09:21:29 +00:00
|
|
|
lda #<0
|
|
|
|
sta.z j
|
|
|
|
sta.z j+1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2020-02-23 08:44:36 +00:00
|
|
|
// for(signed int j = 0; j < 17; j++)
|
2019-09-14 09:21:29 +00:00
|
|
|
lda.z j+1
|
2019-09-29 21:13:37 +00:00
|
|
|
bmi __b2
|
2019-09-14 09:21:29 +00:00
|
|
|
cmp #>$11
|
2019-09-29 21:13:37 +00:00
|
|
|
bcc __b2
|
2019-09-14 09:21:29 +00:00
|
|
|
bne !+
|
|
|
|
lda.z j
|
|
|
|
cmp #<$11
|
2019-09-29 21:13:37 +00:00
|
|
|
bcc __b2
|
2019-09-14 09:21:29 +00:00
|
|
|
!:
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-09-14 09:21:29 +00:00
|
|
|
rts
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2020-02-23 08:44:36 +00:00
|
|
|
// process_name[j]=name[j]
|
2019-09-14 09:21:29 +00:00
|
|
|
clc
|
2020-10-12 18:28:00 +00:00
|
|
|
lda.z j
|
|
|
|
adc #<main.name
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __1
|
2020-10-12 18:28:00 +00:00
|
|
|
lda.z j+1
|
|
|
|
adc #>main.name
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __1+1
|
2019-09-14 09:21:29 +00:00
|
|
|
clc
|
2020-10-12 18:28:00 +00:00
|
|
|
lda.z j
|
|
|
|
adc #<process_name
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __2
|
2020-10-12 18:28:00 +00:00
|
|
|
lda.z j+1
|
|
|
|
adc #>process_name
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __2+1
|
2019-09-14 09:21:29 +00:00
|
|
|
ldy #0
|
2019-09-29 21:13:37 +00:00
|
|
|
lda (__1),y
|
|
|
|
sta (__2),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// for(signed int j = 0; j < 17; j++)
|
2019-09-14 09:21:29 +00:00
|
|
|
inc.z j
|
|
|
|
bne !+
|
|
|
|
inc.z j+1
|
|
|
|
!:
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b1
|
2019-09-14 09:21:29 +00:00
|
|
|
}
|