Re: Apple III Business BASIC Invokables



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...
.



Relevant Pages

  • Re: (part 10) More Schildt-like errors in Dicky Heathens book
    ... like mallocif mallocreturns a non-NULL pointer. ... If one is using a debugging malloc which checks that all accesses are ... when sz is zero, it gives the debugging allocator an opportunity to ...
    (comp.lang.c)
  • Re: Triplet 630APL meter movement adjustment
    ... was the same whether the meter was standind up or laying down. ... mechanical zero with the unit in the vertical position and took a ... There are three weights on the bottom of the meter pointer; ...
    (sci.electronics.repair)
  • Re: (MS-)DOS PC on a microcontroller??
    ... memory block of zero bytes. ... The pointer returned if the ... Each such allocation shall yield a pointer to ... support malloc/calloc requests for 0 bytes and whether or not the ...
    (comp.arch.embedded)
  • Re: (MS-)DOS PC on a microcontroller??
    ... memory block of zero bytes. ... all of malloc, realloc, and calloc and thus is isolated in the ... The pointer returned if the ... Each such allocation shall yield a pointer to ...
    (comp.arch.embedded)
  • Getting a FILE struct pointer with _openfd in assembler
    ... _fdopen passing in 1 and retrieving the FILE struct pointer that way. ... I assemble and link with: ... movl %eax, ptr ...
    (comp.lang.asm.x86)