I am trying to understand control flow in 6502 assembly.
Say I have the following code:
Personally, I would love a switch statement or some other control flow structure. The JMP above concerns me as well. It seems like there is a better way to handle multiple cases without this type of spaghetti code.
Say I have the following code:
Code:
; using asm6
ControlFlow:
lda mem
cmp #1
bne @sub_one
cmp #2
bne @sub_two
@sub_one:
; sub routine one goes here
jmp @done ; <-------------- without this jmp, @sub_two will execute
@sub_two:
; sub routine two goes here
@done:
rts
ControlFlow:
lda mem
cmp #1
bne @sub_one
cmp #2
bne @sub_two
@sub_one:
; sub routine one goes here
jmp @done ; <-------------- without this jmp, @sub_two will execute
@sub_two:
; sub routine two goes here
@done:
rts
Personally, I would love a switch statement or some other control flow structure. The JMP above concerns me as well. It seems like there is a better way to handle multiple cases without this type of spaghetti code.