Over Writing Memory

Basic and Machine Language

Moderator: Moderators

Post Reply
Devlin
Vic 20 Amateur
Posts: 69
Joined: Sun Oct 16, 2005 8:46 pm

Over Writing Memory

Post by Devlin »

Hello,
Ok I know that if you have a program up and running you can have the Vic load in another program with Load"Game",8
Is there a way or a poke that can be typed in before the load command that will make the new load into fresh memory with nothing in it?
if not I understand that the new program just overwrites the old one.
10 print "Hi"
20 load"hello",8

Then Hello runs over old program in memory.
but is there still garbage left in memory from old program.
User avatar
Mike
Herr VC
Posts: 4839
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Hi, Devlin, did you read my reply here?

Otherwise I don't understand why you are concerned about the remnants of the first program. No program should depend on contents of memory locations it has never touched before.

Michael
Thomas Hechelhammer
Vic 20 Dabbler
Posts: 79
Joined: Thu Jun 09, 2005 11:51 pm
Location: Germany

Post by Thomas Hechelhammer »

You can do the following:

Code: Select all

10 PRINT"TEXT"
15 S=S+1:IF S>1 THEN 30
20 LOAD"LEVEL01",8,1: REM loads level1 into memory, absolute
30 REM continue of program
40 IFS>2 THEN 60
50 LOAD"LEVEL02",8,1: REM loads level2 into memory, absolute
After the LOAD-Command is performed the BASIC will be started in the beginning, here with line 10.
But, no CLR will be performed and all the variables are still in memory.
I've added a counter-variable S to see how often the program has been restarted after a LOAD-command.

Make sure that the "thing" you want to load goes in a part of memory which is reserved for the data and not used by BASIC-code or the variables.
You can do this with changing adresses $002D/002E (End of BASIC) but please BEFORE you start your program.

When you want to add line to your existing program, you'll need a MERGE-command.
You'll need the module "programmers-aid" for this.

With such a BASIC-extension it's possible to merge 2 existing programs to one, but you have to keep an eye on the line-numbers because the added program needs to have higher numbers than the first program.
And all variables will be cleared.

-- Thomas
Post Reply