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
|
|
|
|
b1:
|
|
|
|
cpx #1
|
|
|
|
beq b2
|
|
|
|
cpx #2
|
|
|
|
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
|
|
|
|
beq b3
|
|
|
|
cpx #4
|
|
|
|
beq b4
|
2019-08-25 20:21:56 +00:00
|
|
|
// No case for 0 & 5
|
|
|
|
lda #'d'
|
|
|
|
sta SCREEN,x
|
|
|
|
b6:
|
|
|
|
inx
|
|
|
|
cpx #6
|
|
|
|
bne b1
|
|
|
|
rts
|
2019-08-12 19:46:01 +00:00
|
|
|
b4:
|
|
|
|
lda #'4'
|
|
|
|
sta SCREEN,x
|
|
|
|
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
|
|
|
|
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
|
|
|
|
jmp b6
|
|
|
|
}
|