[net.micro.cbm] long pauses when running C64 basic

mp@allegra.UUCP (Mark Plotnick) (11/10/84)

I'm running a terminal/modem program written in Basic (basically the
program from Byte earlier this year).  It uses strings, but they're all
initialized at the beginning of the program and never grow or shrink
thereafter.  Yet I still occasionally see basic pausing for 25 seconds
or so, presumably doing a garbage collection.  Is there any way to
avoid this?  It's not the delay that's the problem, but the resulting
loss of characters from the host is.
	Mark Plotnick
	{far too many sites}!allegra!mp

ericksen@unc.UUCP (James P. Ericksen) (11/13/84)

.
	The reason you are getting garbage collects is that the BASIC
GET# instruction, which you are probably using to read the serial port,
allocates a new string buffer to put the character in every time the 
instruction is used.  The only way around that, though not too difficult,
is to avoid using the GET# instruction in your terminal emulator and
get the characters using a short machine language routine to call the
appropriate kernel routines.  Just poke the sequence

  162, 2, 32, 198, 255, 32, 228, 255, 133, 3, 162, 0, 32, 198, 255, 96

into your favorite unused memory area, SYS to it, and a character will
be magically left at location 3.  From that point, PEEK(3) will give
you what you would have gotten from GET#n.  And no more garbage collects!

Jim Ericksen
Dept of Comp Sci
UNC Chapel Hill

kurt@fluke.UUCP (Kurt Guntheroth) (11/15/84)

There should be another way to get around the garbage collects.  In
microsoft BASIC, the FRE function does a garbage collect before reporting
the free memory space.  If you do a X=FRE(X) every couple hundred GET#'s,
the garbage collection will be performed in a situation where there is
little garbage, which will minimize the length of dead time during the
garbage collect.  This will allow you to use BASIC's admittedly pitiful I/O
rather than resorting to peeks and pokes.
-- 
Kurt Guntheroth
John Fluke Mfg. Co., Inc.
{uw-beaver,decvax!microsof,ucbvax!lbl-csam,allegra,ssc-vax}!fluke!kurt

dpa@ubu.UUCP (David Angier) (11/20/84)

Newsgroups: net.micro.cbm
Subject: Re: long pauses when running C64 basic
References: <85@unc.UUCP> <43@vax2.fluke.UUCP>

> There should be another way to get around the garbage collects.  In
> microsoft BASIC, the FRE function does a garbage collect before reporting
> the free memory space.  If you do a X=FRE(X) every couple hundred GET#'s,
> the garbage collection will be performed in a situation where there is
> little garbage, which will minimize the length of dead time during the
> garbage collect.  This will allow you to use BASIC's admittedly pitiful I/O
> rather than resorting to peeks and pokes.

I'm afraid to say this method will make programs that use lots of string
space slower in I/O rather than faster.  If this is the case use the
PEEK/POKE methos described in a previous article.

bllklly@uwmacc.UUCP (Bill Kelly) (12/05/84)

In article <43@vax2.fluke.UUCP> kurt@fluke.UUCP (Kurt Guntheroth) writes:
>There should be another way to get around the garbage collects.
>If you do a X=FRE(X) every couple hundred GET#'s,
>the garbage collection will be performed in a situation where there is
>little garbage, which will minimize the length of dead time during the
>garbage collect.

I saw an article, I believe by Jim Butterfield, which said the major delay
in C64 garbage collection was in looking for the garbage, not in freeing
it, and hence using FRE() would not help.
-- 

Bill Kelly
{allegra, ihnp4, seismo}!uwvax!uwmacc!bllklly
1210 West Dayton St/U Wisconsin Madison/Mad WI 53706

"Sometimes, Penfold, I wish I was just drawing the cartoons,
 not starring in them."