2019-02-17 23:12:29 +00:00
|
|
|
// Tests that casting inside constants in the output handles precedence between cast and + correctly - should generate the following KA-expression ($ff & sumw>>1)+1
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="cast-precedence-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
|
2018-03-05 00:00:33 +00:00
|
|
|
:BasicUpstart(main)
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2018-03-05 00:00:33 +00:00
|
|
|
main: {
|
|
|
|
.const min = $a
|
|
|
|
.const max = $c8
|
2018-03-11 17:44:47 +00:00
|
|
|
.const sumw = min+max
|
2019-05-18 19:37:34 +00:00
|
|
|
.const sumb = min+max
|
2018-03-10 16:06:42 +00:00
|
|
|
.const midw = (sumw>>1)+1
|
2019-10-20 15:06:17 +00:00
|
|
|
.const midb = (sumb>>1)+1
|
2020-04-30 20:15:59 +00:00
|
|
|
.label SCREEN = $400
|
2020-05-02 09:38:51 +00:00
|
|
|
.label BG_COLOR = $d021
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[0] = midw
|
2018-03-05 00:00:33 +00:00
|
|
|
lda #midw
|
2018-08-22 10:40:19 +00:00
|
|
|
sta SCREEN
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[1] = midb
|
2018-03-05 00:00:33 +00:00
|
|
|
lda #midb
|
|
|
|
sta SCREEN+1
|
2020-02-23 08:44:36 +00:00
|
|
|
// if(SCREEN[0]==SCREEN[1])
|
2018-08-22 10:40:19 +00:00
|
|
|
lda SCREEN
|
2018-04-21 19:38:30 +00:00
|
|
|
cmp SCREEN+1
|
2019-09-29 21:13:37 +00:00
|
|
|
beq __b1
|
2020-05-02 09:38:51 +00:00
|
|
|
// *BG_COLOR = 2
|
2018-04-21 19:38:30 +00:00
|
|
|
lda #2
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2018-03-05 00:00:33 +00:00
|
|
|
rts
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2020-05-02 09:38:51 +00:00
|
|
|
// *BG_COLOR = 5
|
2018-04-21 19:38:30 +00:00
|
|
|
lda #5
|
2020-05-02 09:38:51 +00:00
|
|
|
sta BG_COLOR
|
2019-04-02 06:28:13 +00:00
|
|
|
rts
|
2018-03-05 00:00:33 +00:00
|
|
|
}
|