Re: Apple III Business BASIC Invokables
- From: David Schmenk <dschmenk@xxxxxxxxxxxxx>
- Date: Thu, 04 Dec 2008 07:51:25 -0800
John B. Matthews wrote:
In article <1f042006-37b5-4be3-80c9-1680bd890de0@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
schmidtd <schmidtd@xxxxxxxxxxx> wrote:
Does anyone have experience and/or pointers to using invokable modules[...]
to pass data back and forth from assembly to Business BASIC in the
Apple ///? I'm following an example John Jeppson wrote here:
http://adtpro.sourceforge.net/archive/AppleIIIBits.html
(see the very end of the article.)
I'm modifying it to do my own bidding, namely pass in (a reference to
an) integer variable from BASIC, modify it in assembly, and have that
modified variable be visible back in BASIC again. Trouble is... I
don't see the changes in BASIC.
So, trouble is... I don't see the changes in BASIC. What other examples of invokable module source exists out there? (Oh, one more tidbit... I'm using Apple II Pascal 1.3 to assemble to a Pascal object module, then transfer to a physical /// disk... shouldn't matter, and it's so much easier than using the physical /// machine for everything...)
Dave: FWIW, here's an example written for Apple Pascal 1.3. Using an Integer offset passed by copy, I modify a buffer passed by address. In Pascal, I can use zero page memory locations 0..35; the example uses $E8; you use $E0. Does that make a difference?
<http://home.roadrunner.com/~jbmatthews/a2/zap.html>
John-
I think the issue lies with the way the Apple III uses pointers. The Apple III uses a segmented address architecture, not unlike the 8086, even though it is still a 6502. It pulls this off with extra hardware to snoop zero page address read/writes used by indirect indexed addressing mode instructions. Another page in memory holds the X-byte, basically the segment of the address, to calculate the absolute address. On top of that, 32K chunks of memory can be bank swapped into the middle of the 6502 address space and addressed directly.
When you get a 16 bit pointer to a buffer, it appears that you have to determine if it is an absolute pointer to somewhere in the current 64K, or an indirect pointer that has been already set up in the zero page/X-byte page. According to the documentation I read, if the high address byte is zero then the indirect pointer is already set up in the zero page and you could access it easily by loading the X register with the low byte and using ($00,X). Otherwise, you can put the absolute pointer into an available zero page location and set the X-byte to zero (signifying an address in the current mapping) and access the buffer as you would on any 6502. In the indirect mode, there is a bit of work to do to increment the pointer. One has to check for segment wrapping and update the X-byte if needed. Sound familiar to any old skool 8086 programmers?
That is my understanding, anyway.
Dave...
.
- References:
- Apple III Business BASIC Invokables
- From: schmidtd
- Re: Apple III Business BASIC Invokables
- From: John B. Matthews
- Apple III Business BASIC Invokables
- Prev by Date: Re: Apple III Business BASIC Invokables
- Next by Date: Re: Apple III Business BASIC Invokables
- Previous by thread: Re: Apple III Business BASIC Invokables
- Index(es):
Relevant Pages
|