Page 1 of 1

Program that adds statements to a BASIC program

Posted: Sat Nov 07, 2015 9:30 am
by mrtinb
Hi :)

I would like to modify a BASIC program via BASIC (or ML).

It’s easy to read from the BASIC program, as that starts at address PROGRAM 16509/407D.

It should also be relatively simple to modify the program, as long as it’s modifying from one char to another.

The problem arises when you want to insert new lines into the BASIC program. Then the whole memory has to be pushed forward in memory.

Is there any subroutines in ROM that does this, I can use?

I know from Commodore 64 it was possible to fill the keyboard buffer with chars e.g. “50 PRINT A$<NL>” and this statement would be executed resulting in a new line added to the program.

From reading the ‘ROM Disassembled’-book for ZX81, it seems like there’s no keyboard buffer, and routine that inserts statements into the BASIC program, reads directly from the keyboard.

Any thoughts on this?

/Martin

Re: Program that adds statements to a BASIC program

Posted: Sat Nov 07, 2015 11:20 am
by siggi
Yes, there is a ROM routine, which can be used (of course in FAST mode) to make space anywhere (e. g. in program or variable section) and which also updates the pointers in the system variables, which are affected by that. I used this routine in MEFISDOS (m/c) to insert BASIC lines into an existing BASIC program.
I will post the code later ...

Siggi

Re: Program that adds statements to a BASIC program

Posted: Sat Nov 07, 2015 3:25 pm
by siggi
Hi Martin
the routine to make space is located at $99E in ROM. BC register must hold the size of the memory block needed, HL points to the address, where the space is needed.

Code: Select all

ld BC, length
ld HL, address
call $99e
After that, you can "poke" that space to get the new BASIC line there.

Wilf Rigter's RAMDOS is an example, how to insert a BASIC-program or variables to an existing program:
http://www.user.dccnet.com/wrigter/inde ... RAMDOS.htm

See label "LOADB" in the RAMDOS listing:
http://www.user.dccnet.com/wrigter/inde ... RD2SRC.txt

HTH Siggi

Re: Program that adds statements to a BASIC program

Posted: Mon Jan 25, 2016 4:12 pm
by mrtinb
Thank you very much.

It was just What I needed.

/Martin

Re: Program that adds statements to a BASIC program

Posted: Wed Mar 16, 2016 6:14 pm
by Math123
Hi Martin,

some times ago I made a Basic program that can add Basic-lines at its end. It uses only PEEK and POKE and a tricky hack to make space.
genline.p
(2.16 KiB) Downloaded 235 times
I am still looking to find a way for deleting lines...
If there is a solution, then someone could make a Basic-program that ist able to replicate and/or modify itself. :shock:

Matthias

Re: Program that adds statements to a BASIC program

Posted: Wed Mar 16, 2016 7:14 pm
by Andy Rea
Haha cool, could this.be the beginning of a virus for zx81 ?::

Re: Program that adds statements to a BASIC program

Posted: Thu Mar 17, 2016 12:15 am
by 1024MAK
ZeddySkyNet :shock: :?

Re: Program that adds statements to a BASIC program

Posted: Thu Mar 17, 2016 3:34 pm
by siggi
Math123 wrote:Hi Martin,

some times ago I made a Basic program that can add Basic-lines at its end. It uses only PEEK and POKE and a tricky hack to make space.
genline.p
I am still looking to find a way for deleting lines...
Did you try "THE 'RECLAIMING' SUBROUTINES"?

http://k1.spdns.de/Vintage/Sinclair/80/ ... ra%29.html

Siggi