Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!randy From: randy@athena.mit.edu (Randall W Winchester) Newsgroups: comp.sys.cbm Subject: Re: A fast-blast to basic variables on the C128 Message-ID: <1991Jan7.213923.19427@athena.mit.edu> Date: 7 Jan 91 21:39:23 GMT References: <19278@hydra.gatech.EDU> <1991Jan7.183813.6939@news.nd.edu> Sender: news@athena.mit.edu (News system) Reply-To: randy@mit.edu (Randall W Winchester) Organization: Massachusetts Institute of Technology Lines: 60 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 * *******************************************************************************