Placeholders in assembly: How is it done?

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
N2TheRed
Posts: 24
Joined: 11 May 2016
Location: Texas

Re: Placeholders in assembly: How is it done?

Post by N2TheRed »

whartung wrote:
The only real problem with pushing the elements on the stack is that it's not really a viable option on the 6502, not on the system stack at least, and especially not string values. You can push them on A stack (Forth uses the top of Zero page and indexes with X), but that's using X as your stack pointer, vs the systems. You also still have the problem with stack scarcity for something large like a string.

You could still use the stack if you just push addresses (address of the pattern string, address of the list of arguments (which can be 2 byte integers, or pointers), and the address of the destination buffer).
I see that being a problem when I try this on the 6502 as I'm having to juggle registers on x86.

What I've done on my x86 project is push the address of the pattern string and all string arguments onto the stack. Value arguments are just passed as such.
Last edited by N2TheRed on Thu Aug 03, 2017 11:03 pm, edited 1 time in total.
User avatar
N2TheRed
Posts: 24
Joined: 11 May 2016
Location: Texas

Re: Placeholders in assembly: How is it done?

Post by N2TheRed »

I find it hard to believe that I was able to get part of it to work.
Last edited by N2TheRed on Thu Aug 03, 2017 11:04 pm, edited 5 times in total.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Placeholders in assembly: How is it done?

Post by GARTHWILSON »

I think the 6502 stacks treatise will be very helpful, especially the following chapters (although it's good to read it all, in order):
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
User avatar
N2TheRed
Posts: 24
Joined: 11 May 2016
Location: Texas

Re: Placeholders in assembly: How is it done?

Post by N2TheRed »

GARTHWILSON wrote:
I think the 6502 stacks treatise will be very helpful, especially the following chapters (although it's good to read it all, in order):
I have that saved to my favorites!
Post Reply