2019-08-12 19:46:01 +00:00
|
|
|
// Tests simple switch()-statement
|
|
|
|
// Expected output 'd1444d'
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
|
|
|
ldx #0
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-08-12 19:46:01 +00:00
|
|
|
cpx #1
|
2019-09-29 21:13:37 +00:00
|
|
|
beq __b2
|
2019-08-12 19:46:01 +00:00
|
|
|
cpx #2
|
2019-09-29 21:13:37 +00:00
|
|
|
beq __b3
|
2019-08-18 19:55:21 +00:00
|
|
|
// A case with no body
|
2019-08-12 19:46:01 +00:00
|
|
|
cpx #3
|
2019-09-29 21:13:37 +00:00
|
|
|
beq __b3
|
2019-08-12 19:46:01 +00:00
|
|
|
cpx #4
|
2019-09-29 21:13:37 +00:00
|
|
|
beq __b4
|
2019-08-25 20:21:56 +00:00
|
|
|
// No case for 0 & 5
|
|
|
|
lda #'d'
|
|
|
|
sta SCREEN,x
|
2019-09-29 21:13:37 +00:00
|
|
|
__b6:
|
2019-08-25 20:21:56 +00:00
|
|
|
inx
|
|
|
|
cpx #6
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2019-08-25 20:21:56 +00:00
|
|
|
rts
|
2019-09-29 21:13:37 +00:00
|
|
|
__b4:
|
2019-08-12 19:46:01 +00:00
|
|
|
lda #'4'
|
|
|
|
sta SCREEN,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b6
|
|
|
|
__b3:
|
2019-08-18 19:55:21 +00:00
|
|
|
// A case with fall-through
|
2019-08-12 19:46:01 +00:00
|
|
|
lda #'3'
|
|
|
|
sta SCREEN,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b4
|
|
|
|
__b2:
|
2019-08-18 19:55:21 +00:00
|
|
|
// A simple case with a break
|
2019-08-12 19:46:01 +00:00
|
|
|
lda #'1'
|
|
|
|
sta SCREEN,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b6
|
2019-08-12 19:46:01 +00:00
|
|
|
}
|