[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Extending Applesoft with Ampersand routines.
- Subject: Extending Applesoft with Ampersand routines.
- From: BLuRry <brendan.robert@gmail.com>
- Date: Tue, 12 Mar 2013 10:30:37 -0700 (PDT)
- Complaints-to: groups-abuse@google.com
- Injection-date: Tue, 12 Mar 2013 17:30:38 +0000
- Injection-info: glegroupsg2000goo.googlegroups.com; posting-host=70.112.157.51; posting-account=HyIOQgoAAAAfAUGOevdCSBhPYcDSPtM9
- Newsgroups: comp.sys.apple2
- User-agent: G2/1.0
I'm starting this as a new thread since Bill Buckels asked a very good question as a response to my smart-ass response to a cross-post.
Here is what I know about ampersand routines from a high-level:
You register your ampersand routine handler as a memory pointer, and your routine is called by the applesoft interperter (only at runtime) when it encounters the & sign.
Applesoft pointers indicate the current memory address where the parser was looking (I can't remember if it is the location where & occurs or the memory location just after it).
It is up to your routine to parse as much or as little as it wants, and I believe your parsing routine has to update the applesoft pointer(s) as well. This allows you to do some very wonderful and complex things, or also very simple ones.
And this is the part that eluded me when I experimented with this stuff in the 90's: Your parser will encounter tokenized applesoft statements. That means if your code looks like: &HOME then the actual data will be the tokens &(0xAF) and HOME (0x97). You can use this to your advantage by reusing applesoft tokens for your amp commands instead of having to compare letter after letter (which is the case if the characters do not have the hi-bit set) Some tokens have the open paren or equal sign as part of the token as well.
As for the ins and outs of how to return out of an ampersand command, again it goes back to the applesoft zero-page locations. I can't remember if you have to clear/set the carry as a status bit like you do in other Apple firmware routines but it wouldn't surprise me if CLC meant there was no error and SEC meant there was.
Also, here's a list of all the applesoft tokens as well as my applesoft de-tokenizer routine:
http://sourceforge.net/p/java-ace/code/285/tree/jace/src/jace/applesoft/Command.java
I hope this helps. I can dig up some better information if this is insufficient.
-Brendan