[comp.sys.cbm] A fast-blast to basic variables on the C128

treesh@vangogh.helios.nd.edu (01/08/91)

Ok guys, this is the deal, I got a C128, running in 80 col mode, and 
I have poked a string of ascii bytes into seccessive ram locations 
startting at address 7377 (base 10).  I need a very fast way to get this
string of bytes into the basic A$.  I wanna do it in ML, and I want it to
be very quick!  Like 200 bytes/second transfer rate to the basic A$ 
variable.  

At address 7376 contains the lenght of the data-string, including the 13
which terminates the string.  When transfered to A$, the 13 need not be
part of the string.  Thus the LEN(a$) when done will be = to peek(7376)-1.

Anyone have any idea how I can accomplish this feet??
 
Thanks much, Send follow up, or e-mail.

ctfm

-----------------
             

randy@athena.mit.edu (Randall W Winchester) (01/08/91)

In article <1991Jan7.183813.6939@news.nd.edu>
treesh@vangogh.helios.nd.edu writes:
>Ok guys, this is the deal, I got a C128, running in 80 col mode, and 
>I have poked a string of ascii bytes into seccessive ram locations 
>startting at address 7377 (base 10).  I need a very fast way to get this
>string of bytes into the basic A$.  I wanna do it in ML, and I want it to
>be very quick!  Like 200 bytes/second transfer rate to the basic A$ 
>variable.  
>
>At address 7376 contains the lenght of the data-string, including the 13
>which terminates the string.  When transfered to A$, the 13 need not be
>part of the string.  Thus the LEN(a$) when done will be = to peek(7376)-1.
>
>Anyone have any idea how I can accomplish this feet??

Well, I did something like this for a fast ASCII<->PETASCII conversion
routine to be called from BASIC.  The following is not real code, but
a few suggestions; hopefully you can adapt these suggestions to your
job.

Start out with:

10 a$="0123456789012345678901234567890123456789"

This reserves your variable space for a$.  A$ must be the first
variable in the program, set to the maximum length of expected input.

Somewhere in the program you can then use the BASIC 7.0 POINTER
function to find out where in memory a$ is located.  The address
returned by the POINTER function is the variable header.  You'll have
to split the address into it's low and high byte values.  Once you do
that, you can pass the values to your ml routine with the BASIC 7.0
SYS command (SYS addr,a,x,y).  

Somewhere in the C128 Programmer's Reference Guide is a description of
the different variable formats.  Here's where my memory is a little
fuzzy.  I believe the header for a string variable consists of two
bytes for the name followed by the address of the string itsself (2
bytes), followed by the length of the string (1 byte).

The header and data for a$ are in BANK 1.  Your machine code will have
to use a loop to read your data from 7377, then use the INDSTA kernal
routine to store the bytes in the data portion of a$.  After copying
the string, copy the length byte from 7376 to the length byte in the
string header.  Then RTS back to BASIC and your string should be in
place.

Sorry I can't be more specific, but I don't have quick access to my
C128 books.  Hopefully someone can correct any mistakes I've made, but
the general process works, and should be easy to adapt to your project.

>Thanks much, Send follow up, or e-mail.
>
>ctfm
>
>-----------------
>             
*******************************************************************************
*  Randy Winchester  *  randy@mit.edu  *  PO Box 1074, Cambridge, MA  02142   *
*******************************************************************************

treesh@vangogh.helios.nd.edu (01/08/91)

Randy, I would like to thank you very much for your help on this project, 
this information you have given should make my job of getting a high-speed
data-to-basic string variable routine much faster then the way I was doing
it before in basic.  Im going to slightly modify your idea in that Im going
to assign the variable a$ and give it about 200 charectors in lenght.  Then
instead of altering the lenght of this entry in the table, I will just copy
the needed bytes, leaving the rest of the string untouched.  With the 
use of the basic LEFT$(a$,peek(lenght)) should work quite niclely.  Thanks
again.

ctfm