[comp.sys.apple] HELP, //c program

hood@osiris.UUCP (07/13/87)

I am in the process of writing a program that needs a bunch of memory
buffer area.  As a result,  I have the need to transfer program control
over to the aux. 48K and work from there for a while.  My question comes
in how to do the transfer without getting lost ??

I am writing the program in assembly language and all the documentation
that I can find tells me to do the following:

set or clear the carry flag (depending on which way to transfer)
put the starting address in  $03de, 03df (I think those are the right #'s)
and then do a jump (4c) to $c314

Just previous to this I have moved a section of the main program to the 
new location but after executing the jump,  I end up breaking at some point
in the system global page and I never do execute any of the commands at
the new location.

Another related question is how (if it can be done) do you look at the
aux memory locations from the monitor prompt???

thanks for your help on this, I can't go on until this bridge is crossed.


Stan Seago				US Army, HQ III Corps & Fort Hood
UUCP..!ihnp4!uiucuxc!fthood!sseago	Attn: AFZF-DE-ENV
					DEH, Environmental Management Office
					Fort Hood, TX 76544-5057

ranger@ecsvax.UUCP (Rick N. Fincher) (07/16/87)

In article <9300004@osiris>, hood@osiris.cso.uiuc.edu writes:
> 
> 
> 
> 
> I am in the process of writing a program that needs a bunch of memory
> buffer area.  As a result,  I have the need to transfer program control
> over to the aux. 48K and work from there for a while.  My question comes
> in how to do the transfer without getting lost ??
> 
> I am writing the program in assembly language and all the documentation
> that I can find tells me to do the following:
> 
> set or clear the carry flag (depending on which way to transfer)
> put the starting address in  $03de, 03df (I think those are the right #'s)
> and then do a jump (4c) to $c314
> 
> Just previous to this I have moved a section of the main program to the 
> new location but after executing the jump,  I end up breaking at some point
> in the system global page and I never do execute any of the commands at
> the new location.
> 
> Another related question is how (if it can be done) do you look at the
> aux memory locations from the monitor prompt???
> 
When you enable auxmem only the main 48K of memory (exclusive of zero page
and the stack) is switched.  Zero page and the stack are switched with other
soft switches, as is the upper 16K (bank switched RAM).  Put your bank switch-
ing routine in either zero page (hard to do because of space limits) or in the 
bank switched RAM area (not much room here either, under Prodos, but you can
probably get away with using the "Reserved for future use" areas that are not
used in current versions of Prodos.  When you switch the banks this way your
program execution does not instantly switch to the other bank, and you can
jump to the needed routine in the normal manner.  Be careful of your stack
and zero page if you have things in either bank that depend on them.  Ifyou 
absolutely must put your routine in the lower 48K, put an identical copy of the
routine in the other bank.  This will allow the program to continue as if 
nothing happened after the bank is switched.  You can write the routine in
such a way that it checks to see what bank it is in so that you can toggle
banks by repeated JMP's or JSR's to the routine.  If you want your JSR's to work
properly, though, you must be sure to set the proper zero page and stack for
each bank, else the routine will RTS to an address that was pushed on the 
stack in the other bank.

As far as looking at the aux RAM with the monitor, Call Apple had some routines
a few years ago that modified the monitor to do this.  The //gs monitor will
let you look at any bank too.  If memory serves me, I think you can lookat the
lower 48K as long as the monitor ROM is enabled (Bank switched Ram disabled)
and if you need to use the BSR in the aux mem you can copy the ROM from $F800
into the aux ram and use a ram based monitor (I don't remember if the zero 
page and page 3 vectors prevent this from working though).  A good book for
doing this sort of thing is Gary Little's "Inside the Apple IIe" published
by Brady, I think.  He has an example of copying Basic to the aux Ram and run-
ning two Basic programs simultaneously in different ram banks.  A certain key
suspends one program and enables the one in the other bank. No Prodos access
can be performed with auxmem enabled, however, because the System Global Page
and Bitmap reside in the lower 48K of main Ram only.

hope this helps,

Rick Fincher
ranger@ecsvax
> thanks for your help on this, I can't go on until this bridge is crossed.