Moving basic memory while running?
Moderator: Moderators
Moving basic memory while running?
If I for example have the basic memory set to address 4608, and then load a basic program to address 8192. Can I then do anything to move the basic memory and run that program at 8192? I know how to first move the memory and then load and run (poke8192,0:poke44,32:new), but if I want to do it in the opposite order? First load and then move memory pointers to that loaded program then run. This would allow me to make 1 file games for the expanded vic, rather than 2 or 3 part games...
/Anders
/Anders
You'll need to set the pointers as follows.Can I then do anything to move the basic memory and run that program at 8192?
Code: Select all
Address Pointer Value
------- ------------------ -----
43-44 Start of Basic 8192
45-46 Start of Variables First byte after program
47-48 Start of Arrays First byte after program
49-50 End of Arrays First byte after program
51-52 String storage End of memory+1
You may only need to set the start of basic and the start of variables and then do CLEAR:RUN or even just RUN may work as it does an implied CLEAR first.
I could be one byte out with some values, it's been a while. 8^)=
Cheers,
Lee.
Lee is perfectly correct, which I just verified through emulation (yes, I know I'm a bastard for praising emulation, but since the ROM code should be identical to the real thing, I believe in the results).
1. I started the VIC with 8K expansion memory, issued POKE 44,32:POKE 8192,0:NEW
2. Then I entered a small 10 PRINT"BLAH":GOTO 10 program
3. Then I poked back with POKE 44,18:POKE 4608,0:NEW
4. The program at 8192 is kept intact
5. I run this one-liner 10 POKE 44,32:POKE 8192,0:RUN
Voila! Basic and all the pointers move accordingly and the program starts right away. If you for some reason want to do it the machine code/SYS way, the calls are:
NEW = JSR $C642 (SYS 50754)
CLR = JSR $C65E (SYS 50782)
RUN = JSR $0079:JSR $C659:JMP $C7AE (can not be done through Basic?)
The last line of machine code is very useful if you ever want to start a Basic program from machine language:
$0079 (zero page!) is part of the routine to fetch a byte of Basic text
$C659 resets execution to start of program followed by CLR
$C7AE checks for STOP key and then handles next Basic statement already fetched
It also works perfectly on the C64 if you change the two latter addresses to A659 and A7AE.
1. I started the VIC with 8K expansion memory, issued POKE 44,32:POKE 8192,0:NEW
2. Then I entered a small 10 PRINT"BLAH":GOTO 10 program
3. Then I poked back with POKE 44,18:POKE 4608,0:NEW
4. The program at 8192 is kept intact
5. I run this one-liner 10 POKE 44,32:POKE 8192,0:RUN
Voila! Basic and all the pointers move accordingly and the program starts right away. If you for some reason want to do it the machine code/SYS way, the calls are:
NEW = JSR $C642 (SYS 50754)
CLR = JSR $C65E (SYS 50782)
RUN = JSR $0079:JSR $C659:JMP $C7AE (can not be done through Basic?)
The last line of machine code is very useful if you ever want to start a Basic program from machine language:
$0079 (zero page!) is part of the routine to fetch a byte of Basic text
$C659 resets execution to start of program followed by CLR
$C7AE checks for STOP key and then handles next Basic statement already fetched
It also works perfectly on the C64 if you change the two latter addresses to A659 and A7AE.
Anders Carlsson
There's probably an easier way to do it. After you've loaded the program into memory and done the POKE 44,32 if you call the routine that rebuilds the BASIC line chain it should set all the pointers except the end of memory for you.
I don't have a disassembly of BASIC 2 handy so don't know the entry point to this routine but it's what I do in my 680x0 BASIC after loading a program binary image.
Lee.
I don't have a disassembly of BASIC 2 handy so don't know the entry point to this routine but it's what I do in my 680x0 BASIC after loading a program binary image.
Lee.
There are a few entries to warm-start Basic. I wonder if any of those can be useful. Otherwise, Funet has memory maps etc if one can't find those elsewhere. The all-Basic way should work, or otherwise we have some ideas how to approach in machine code.
680x0 Basic? Is it also derived from Microsoft's one?
680x0 Basic? Is it also derived from Microsoft's one?
Anders Carlsson
It worked! Just as Lee described.... But I found an even simpler way. When a program is loaded, the poiners 45,46 etc. are automatically set to behind the loaded program, and because I have the basic program last in the resulting file, those pointers are set by themselves when the file is loaded. I only have to change the start pointer.
So, if you have the basic starting at 8192, you only have to do the following...
(reset)
10 poke 44,32:run
(make the small basic start)
load "gfx and machine language part",8,1
(loads into the graphics mem)
poke 44,32: poke 32*256,0: new
(move basic to 8192)
load "basic part",8
(load main basic part)
poke 44,18
(move back the beginning of basic to default)
save "whole program",8
(And everything saves as one big file)
Very nice as you don't even have to bother to look what the ending address is...
Thanks again for the help! I will post the result(s) soon in the "expanded programs" section...
Btw, Lee... Your 680x0 basic... Is it for amiga?
/Anders
So, if you have the basic starting at 8192, you only have to do the following...
(reset)
10 poke 44,32:run
(make the small basic start)
load "gfx and machine language part",8,1
(loads into the graphics mem)
poke 44,32: poke 32*256,0: new
(move basic to 8192)
load "basic part",8
(load main basic part)
poke 44,18
(move back the beginning of basic to default)
save "whole program",8
(And everything saves as one big file)
Very nice as you don't even have to bother to look what the ending address is...
Thanks again for the help! I will post the result(s) soon in the "expanded programs" section...
Btw, Lee... Your 680x0 basic... Is it for amiga?
/Anders
No, it's for any 680x0 computer that has at least character I/O. I wrote it because I had a 68008 single board computer and wanted something to interactively manipulate the hardware.
Go see ..
http://www.themotionstore.com/leeedavis ... index.html
for more details.
Lee.
Go see ..
http://www.themotionstore.com/leeedavis ... index.html
for more details.
Lee.
Probably, though it is not OS friendly or even OS aware. I dare say it could be made to work on the bare motherboard by writing some character I/O routines for the serial port (I assume there is one) and making a set of ROMs to replace the Apple ROMs.
It has been ported to the Atari Jaguar, but not by me.
Lee.
It has been ported to the Atari Jaguar, but not by me.
Lee.