[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending Applesoft with Ampersand routines.



On Tuesday, March 12, 2013 3:32:35 PM UTC-5, Michael J. Mahon wrote:
> BLuRry <brendan.robert@gmail.com> wrote:
> 
> > 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
> 
> 
> 
> No, there's no automatic error handling--you have to explicitly report any
> 
> errors. 
> 
> 
> 
> I replied in the original thread before noticing your new one. ;-)
> 
> 
> 
> Check out the AMPERNADA module in my NadaNet source for a compact, quite
> 
> capable ampersand handler. 
> 
> 
> 
> -michael - NadaNet 3.1 and AppleCrate II: http://home.comcast.net/~mjmahon

Top Notch!  Thanks again Michael!!

Did I get the basics right?  I was citing that all from memory and it's been quite a while since I've read about or done anything like that.  I think I was really reciting most of it from what I knew after typing in Nibble listings for some sort of ampersand routine long long ago.

-B