[net.micro.cbm] Thanks for the UN-NEW and here it is...

wargo@sdcsla.UUCP (Dave Wargo) (10/03/84)

Thanks for the UN-NEW programs. I have not tryed either of the two
programs, so those of you who could use it have fun.

================================================================================

From ulysses!ecsvax!calway Sat Sep 22 15:10:27 1984


I assume that you are talking about BASIC programs when you speak of  recovering
one after pressing your warm-start button (I think it really is a cold-start
button, which is why you lose the pointers).
The end of a BASIC program is marked by
three zero-filled bytes in a row.
A line such as the following, entered in the command mode, should find the end
for you:

FORX=2048TO40959:?X:IFPEEK(X)<>0ORPEEK(X+1)<>0ORPEEK(X+2)<>0THENNEXT

A string of addresses will run down the screen and eventually stop. Add three to the last
address and devide that number into high and low bytes:

high byte=INT(address/256)
low byte=address-(high byte*256)

POKE the high byte into addresses 46, 48 and 50. POKE the low byte into 
addresses 45, 47 and 49.
SAVE the program at this point, before 
trying to LIST it, because if the 
line links are messed up (probably aren't, but it pays to be cautious), your
computer may hang again. Now you can
take a look at the LIST. If the LIST
is screwy or hangs your computer, you will need to get a machine language
monitor and go in and fix the line links. Not much fun. 
I hope this helps.


James  Calloway
The News and Observer
Box 191
Raleigh, N.C. 27602
(919) 829-4570
{akgua,decvax}!mcnc!ecsvax!calway







From sdcsvax!ucbvax!allegra!harvard!wjh12!foxvax1!white Fri Sep 28 21:11:31 1984
Subject: Re: Un-new Source for C64

Dave:--

It takes awhile for news to get this far...  In case noone else
replied, the following will poke an assembly language subroutine into
high memory to un-new a program as needed.  The program will erase
itself when it is run via a 'NEW', so you can test it on itself! Be
sure to execute it with  "SYS xxxxx :CLR"  [ the location may be
changed ].

	10 AD=49152 : FOR I= 0 TO 21
	20 READ D : POKE AD + I,D : NEXT
	30 DATA 169, 8, 141, 2, 8, 32, 51, 165, 24
	40 DATA 165, 34, 105, 2, 133, 45, 165, 35
	50 DATA 105, 0, 133, 46, 96
	60 PRINT "EXECUTE WITH SYS "; AD; ":CLR" : NEW

     Here is the disassembly:---

	ORG	$C000	;Starting location (may be relocated)
	LDA	#$08	;put $08 in accum. and adjust the...
	STA	$0802	;...next stmt. MS addr.Byte to proper address
	JSR	$A533	;ROM subroutine: finds program end,puts in $22,$23
	CLC		;clear carry flag
	LDA	$22	;load low byte of pgm. end
	ADC	#$02	;adjust pgm. end low byte
	STA	$2D	;...and save it as start of variables
	LDA	$23	;now, get high byte...
	ADC	#$00	;...adjust high byte, if a carry
	STA	$2E	;...and save it also
	RTS		;Done!

===================================================
	Walt White
	The Foxboro Company
	Foxboro, MA 02035
	..!wjh12!foxvax1!white

I'm not loafing... I just work so fast I'm always FINISHED!