2019-04-08 07:00:48 +00:00
|
|
|
// Tests elimination of plus 0
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="plus-0.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-04-08 07:00:48 +00:00
|
|
|
:BasicUpstart(main)
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-04-08 07:00:48 +00:00
|
|
|
main: {
|
2020-02-23 08:44:36 +00:00
|
|
|
// fill((byte*)$400,'a')
|
2019-04-08 07:00:48 +00:00
|
|
|
ldx #'a'
|
|
|
|
lda #<$400
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z fill.screen
|
2019-04-08 07:00:48 +00:00
|
|
|
lda #>$400
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z fill.screen+1
|
2019-04-08 07:00:48 +00:00
|
|
|
jsr fill
|
2020-02-23 08:44:36 +00:00
|
|
|
// fill((byte*)$2000,'b')
|
2019-04-08 07:00:48 +00:00
|
|
|
ldx #'b'
|
|
|
|
lda #<$2000
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z fill.screen
|
2019-04-08 07:00:48 +00:00
|
|
|
lda #>$2000
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z fill.screen+1
|
2019-04-08 07:00:48 +00:00
|
|
|
jsr fill
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-04-08 07:00:48 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-12-26 08:51:41 +00:00
|
|
|
// fill(byte* zp(2) screen, byte register(X) ch)
|
2019-04-08 07:00:48 +00:00
|
|
|
fill: {
|
|
|
|
.label screen = 2
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __5 = 4
|
|
|
|
.label __7 = 6
|
2019-04-08 07:00:48 +00:00
|
|
|
ldy #0
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2020-02-23 08:44:36 +00:00
|
|
|
// (screen+j*40)[i] = ch
|
2019-04-08 07:00:48 +00:00
|
|
|
txa
|
|
|
|
sta (screen),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// screen+j*40
|
2019-04-08 07:00:48 +00:00
|
|
|
lda #1*$28
|
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z screen
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __5
|
2019-04-08 07:00:48 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z screen+1
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __5+1
|
2020-02-23 08:44:36 +00:00
|
|
|
// (screen+j*40)[i] = ch
|
2019-04-08 07:00:48 +00:00
|
|
|
txa
|
2019-09-29 21:13:37 +00:00
|
|
|
sta (__5),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// screen+j*40
|
2019-04-08 07:00:48 +00:00
|
|
|
lda #2*$28
|
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z screen
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __7
|
2019-04-08 07:00:48 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z screen+1
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __7+1
|
2020-02-23 08:44:36 +00:00
|
|
|
// (screen+j*40)[i] = ch
|
2019-04-08 07:00:48 +00:00
|
|
|
txa
|
2019-09-29 21:13:37 +00:00
|
|
|
sta (__7),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// for(byte i: 0..39)
|
2019-04-08 07:00:48 +00:00
|
|
|
iny
|
|
|
|
cpy #$28
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-04-08 07:00:48 +00:00
|
|
|
rts
|
|
|
|
}
|