I tried to google 6502 "subroutine parameters", but nothing useful came up. So, I'm just asking the question here:
Is there a way in 6502 Assembly to use parameters for subroutines?
Something like this:
And then you call the sub routine like one of these:
Is there a way in 6502 Assembly to use parameters for subroutines?
Something like this:
Code:
MySubRoutine:
; Parameter name: loopCounter
LDX #$00
Loop:
; Do something here.
INX
CPX loopCounter
BNE Loop
RTS
; Parameter name: loopCounter
LDX #$00
Loop:
; Do something here.
INX
CPX loopCounter
BNE Loop
RTS
And then you call the sub routine like one of these:
Code:
JSR MySubRoutine #$10
; Calls MySubRoutine and sets loopCounter to 16.
JSR MySubRoutine $0500
; Calls MySubRoutine and sets loopCounter to the value at address $0500.
; Calls MySubRoutine and sets loopCounter to 16.
JSR MySubRoutine $0500
; Calls MySubRoutine and sets loopCounter to the value at address $0500.