Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #292

Re: split a basic program into two different areas of RAM?

Date 2012-05-06 22:54 +0200
From Linards Ticmanis <ticmanis@gmx.de>
Newsgroups comp.sys.apple2.programmer
Subject Re: split a basic program into two different areas of RAM?
References <dfb6fa60-56d4-42d8-b942-9a5a5b5ef84f@2g2000yqp.googlegroups.com>
Message-ID <4fa6e511$0$9502$9b4e6d93@newsspool1.arcor-online.net> (permalink)
Organization Arcor

Show all headers | View raw


On 05/06/2012 07:48 PM, asdf wrote:
> I assume you could poke 103, 104 with new values, and jmp back to the
> basic
> interpreter to split a basic program?
> 
> IE, program first half at $800 to $1FFF.  second half at $4000 to
> $6000.
> 
> any time you need to get to the second half of the program, call a ML
> program that modifies 103 and 104, then call the interpreter.  you
> would
> need to restore them when program flows back to the first half.

I think you could simply let the next-line pointer of the last program
line in the "lower" part point to $4000, and treat the program as if it
was one single thing. I.e. just GOTO and GOSUB to your heart's content
between the two parts. You might or might not be able to just let it run
past the "break", you'd have to try, I'm not sure if the line linking
pointers are used to find the next line during normal execution, or if
they're only used when you jump.

Of course you can't modify the first part of the program after this:
then the whole scheme would collapse as the BASIC editor doesn't expect
a "break" inside the program.

To get there, you'd need to find out which line is the first in your
program (in its natural state) that crosses $2000. Then move this line
and everything that follows up to $4000 with the monitor, and
re-calculate the line linking pointers and the "program end" pointer. To
do the latter you'd probably need to temporarily change 103/104 then
call the interpreter's recalculation routine and finally restore 103/104
and use the monitor to make the pointer that links the two halves. You
could then SAVE the whole beast, and it should RUN after LOADing without
further ado.

Probably you'd want to automate this whole thing somehow with a bit of
ML code, so that you don't have to do it by hand everytime you change
something in your code. You'd keep one normal version of your program
around to do edits, and then always feed the latest incarnation of that
into the automatic tool, to build something that you can RUN (but not edit).

Note that I haven't actually tried this...

-- 
Linards Ticmanis

Back to comp.sys.apple2.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

split a basic program into two different areas of RAM? asdf <craigslist530@gmail.com> - 2012-05-06 10:48 -0700
  Re: split a basic program into two different areas of RAM? Linards Ticmanis <ticmanis@gmx.de> - 2012-05-06 22:54 +0200
  Re: split a basic program into two different areas of RAM? Michael J. Mahon <mjmahon@aol.com> - 2012-05-06 18:35 -0500

csiph-web