2019-04-07 15:59:44 +00:00
|
|
|
// Tests the ternary operator
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="ternary-1.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-07 15:59:44 +00:00
|
|
|
:BasicUpstart(main)
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-04-07 15:59:44 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
|
|
|
ldx #0
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2020-02-23 08:44:36 +00:00
|
|
|
// i<5?'a':'b'
|
2019-08-25 20:21:56 +00:00
|
|
|
cpx #5
|
2019-09-29 21:13:37 +00:00
|
|
|
bcc __b2
|
2019-08-25 20:21:56 +00:00
|
|
|
lda #'b'
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b3
|
|
|
|
__b2:
|
2020-03-07 21:38:40 +00:00
|
|
|
// i<5?'a':'b'
|
2019-04-07 15:59:44 +00:00
|
|
|
lda #'a'
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[i] = i<5?'a':'b'
|
2019-04-07 15:59:44 +00:00
|
|
|
sta SCREEN,x
|
2020-02-23 08:44:36 +00:00
|
|
|
// for( byte i: 0..9)
|
2019-04-07 15:59:44 +00:00
|
|
|
inx
|
|
|
|
cpx #$a
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-04-07 15:59:44 +00:00
|
|
|
rts
|
|
|
|
}
|