Subroutine parameters
Posted: Tue Mar 13, 2018 1:11 am
Hi,
Programming is nothing new to me, but 6502 assembler is kicking my ass right at the start.
I figured a minimum amount of infrastructure involves being able to pass parameters to a subroutine.
Some people call this inline parameter, immediate embedded data etc.
I've seen examples of people saying this is what they do, but never how they do it.
Basically, the simplest representation of what I want to do is:
Extracting the address a parameter is on using the stack is no problem, but I can't figure out how to access the data in it because it's two bytes and lda ($FF),Y can only access the zero-page area.
I feel like there is a basic and important piece of the puzzle I'm missing.
Could somebody please show me an example of this that works?
It's not important if it's in ACME or tass or whatever, I just need to know how to execute the concept.
Programming is nothing new to me, but 6502 assembler is kicking my ass right at the start.
I figured a minimum amount of infrastructure involves being able to pass parameters to a subroutine.
Some people call this inline parameter, immediate embedded data etc.
I've seen examples of people saying this is what they do, but never how they do it.
Basically, the simplest representation of what I want to do is:
Code: Select all
doSomething:
-magic to get the parameters in to accumulator-
...
rts
...
jsr doSomething
!byte #$12,#$23,#$34,#$45
jsr doSomething
!byte #$23,#$45,#$56,#$12Extracting the address a parameter is on using the stack is no problem, but I can't figure out how to access the data in it because it's two bytes and lda ($FF),Y can only access the zero-page area.
I feel like there is a basic and important piece of the puzzle I'm missing.
Could somebody please show me an example of this that works?
It's not important if it's in ACME or tass or whatever, I just need to know how to execute the concept.