[Coco] MC-10/CoCo BASIC - why did I code this way?
Bill Gunshannon
bill.gunshannon at hotmail.com
Thu Dec 28 19:31:08 EST 2017
Yes, but apparently Radio Shack thought it could be done. :-)
bill
________________________________
From: Coco <coco-bounces at maltedmedia.com> on behalf of William Astle <lost at l-w.ca>
Sent: Thursday, December 28, 2017 7:21 PM
To: coco at maltedmedia.com
Subject: Re: [Coco] MC-10/CoCo BASIC - why did I code this way?
There are a couple of reason it kills program execution when DEL executes.
1. You might be deleting the line you're currently executing.
2. The line you're executing could have been relocated in memory. Oops.
They didn't even get that right with PCLEAR in the first iteration.
3. Variables are stored immediately after the end of the program. If the
program shrinks, the variables have to move.
4. There might string descriptors referencing deleted lines which would
then have to be moved into string space. Which might trigger an ?OS error.
Of course, all of those problems are solvable. For (1), you just move on
to the next line. For (2) and (3), you need to relocate the whole
variable table, etc., which can be done.
(4) is much harder. It requires basically doing a garbage collection
pass but with slightly different logic.
All combined, it would require a nontrivial amount of code vs just
killing off the program execution. And, given that ECB 1.0 got PCLEAR
wrong (and it has to do (2) and (3)), there's no doubt that DEL would
have been really problematic. Still, it would have been better use of
the ROM space than "PRINT USING" was. (USING takes somewhere around 1K
of code and isn't all that useful for general formatting.) Or DLOAD for
that matter.
On 2017-12-28 03:51 PM, Bill Gunshannon wrote:
> Interesting, I thought I remembered doing it in the past and I looked
> it up in my handy, dandy "TRS-80 Computer Reference Handbook",
> cat No. 62-2314 and it specifically listed it as a use for the DEL verb.
>
> "or to delete program lines 'dynamically' to release portions of BASIC
> programs that are no longer needed to create room for variables."
>
> But, I tried it on a COCO3 with ECB and on a Level II Model I and it,
> in fact, did not work.
>
> bill
>
> ________________________________
> From: Coco <coco-bounces at maltedmedia.com> on behalf of Allen Huffman <alsplace at pobox.com>
> Sent: Thursday, December 28, 2017 2:55 PM
> To: CoCoList for Color Computer Enthusiasts
> Subject: Re: [Coco] MC-10/CoCo BASIC - why did I code this way?
>
>> Don't know why someone would do that.
>> It is really easy to write your program so that the DATA does not reside
>> in program and string space when run.
>> 10 DATA "A","B","C"
>> 20 READ A$,B$,C$
>> 30 PRINT A$,B$,C$
>> 40 DEL 10
>> 50 PRINT A$,B$,C$
>> 99 END
>
> This code snippet suddenly made me realize that BASIC would have to check, when using DEL, to see if any strings were in code space. If so, it would have to relocate them. I then thought about all the ways you could make programs init, delete that code, then continue with more RAM for strings and such.
>
> But, it doesn’t look like it works. In a test I just tried, as soon as it hits the DEL, the program stops running.
>
> That would have been cool, though.
>
> — Allen
>
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
--
Coco mailing list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco
More information about the Coco
mailing list