REM Line length

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
Vorticon
Posts: 69
Joined: Tue Mar 01, 2022 1:14 pm

REM Line length

Post by Vorticon »

Hello.
I've recently dug up my TS-1000 computer from storage and have decided to teach myself Z80 assembly on it using Toni Baker's Mastering Machine Code on Your ZX 81 book. I already have substantial assembly language experience with the TMS9900 and 8080 CPUs on other retro platforms so I'm not a total beginner, but doing assembly on the Zeddy hardware (not emulation) appears to be a particular form of masochism :lol:
Nonetheless, I am making heady progress. The book, although advertised as a complete beginner's book, is rather amateurish and leaves a lot of important details. For example, it presents several ways to enter and save machine language code using either REM statements or arrays along with example code, but does not explain what all those mysterious address used are and how the code itself works. I figured it out after gathering scattered information from various sources, but I can see how this would be a very difficult task for a newcomer. And don't get me started about the reference tables at the end of the book which use all sorts of notations nowhere explained in the book. I might as well have been staring at an Aztec codex...

But enough whining. I do have a question: How many characters can be stored in a single REM statement?
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: REM Line length

Post by 1024MAK »

There is the assumption that an owner has read and understood the Sinclair ZX81 BASIC Programming manual (this was supplied as standard with all ZX81 computers, I don’t know if a similar book was supplied with TS1000 or TS1500 computers or other official ‘clones’).

Despite it’s title, the manual goes further than just the normal introduction to BASIC, in chapter 27 it explains the organisation of memory. Essential if you are programming in assembly language. As is chapter 28, where the system variables are detailed.

This manual is available on line if you search for it.
HTML version
PDF version

As is an error corrected HTML of Toni Baker's Mastering Machine Code on Your ZX81 book. Link

This web page is also very useful ;-)

Anyway to answer you question, any BASIC line, including a REM line, uses two bytes for the length, which includes the NEWLINE (end of line) marker.

The practical problem is that of either the actual available memory, or how slow the edit line gets as the line length gets longer…
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: REM Line length

Post by 1024MAK »

Here’s an example showing how long I made a REM line before I got bored…
6AC22A87-88D4-4B4D-9E9F-7A57E4B23C2E.jpeg
If you poke the BASIC program area and change the line length, you can ‘merge’ two consecutive BASIC lines into one longer line. But you must correctly update the line length.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
Vorticon
Posts: 69
Joined: Tue Mar 01, 2022 1:14 pm

Re: REM Line length

Post by Vorticon »

Yes I have read the user's manual for the TS1000 which is where I found out about the way program lines are represented in memory. But nowhere was there a mention of how long a program line can be. Most retro computers limit you to 256 characters. Is that the case here or one can just keep going until the screen is filled up?
roganjosh
Posts: 100
Joined: Thu Jun 14, 2018 12:59 pm

Re: REM Line length

Post by roganjosh »

Vorticon wrote: Fri Mar 11, 2022 9:21 pm Most retro computers limit you to 256 characters. Is that the case here or one can just keep going until the screen is filled up?
You can have a REM statement that fills up most of the available RAM. It'd obviously be tedious to type in though. I wrote a little assembler program a while ago where you're prompted for the number of reserved bytes you want and it produces a REM statement with line number '0' (which normally won't clash with existing lines and also is relatively safe from deletion) containing the required space. The source code is attached along with an assembled binary. It was written to be used under EightyOne so you load the binary in as a block at address 30000 and do a "RAND USR 30000" to start it. The assembly address was chosen arbitrarily. Obviously don't have the REM space ploughing into the machine code routine. You can also enter a hex value if the hex digits are preceded by a '$'.

Alan
Attachments
remmer.zip
(4.46 KiB) Downloaded 96 times
Moggy
Posts: 3267
Joined: Wed Jun 18, 2008 2:00 pm

Re: REM Line length

Post by Moggy »

Just about every toolkit for the 81 included a REM extender of some sort I seem to recall.
I have the Delphic toolkit in EPROM form on a Hunter EPROM board with which I premade a lot of REMs for uses various It's on the forum somewhere as far as I know.
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: REM Line length

Post by 1024MAK »

Vorticon wrote: Fri Mar 11, 2022 9:21 pm Yes I have read the user's manual for the TS1000 which is where I found out about the way program lines are represented in memory. But nowhere was there a mention of how long a program line can be. Most retro computers limit you to 256 characters. Is that the case here or one can just keep going until the screen is filled up?
Because a program line uses two bytes for the length, any program line can be a significant portion of the available RAM. So far in excess of 256 bytes. I say bytes rather than characters, because keywords, such as REM are single byte tokens. And numbers are followed by hidden five byte floating point representations. But obviously it can’t be 64k bytes long, as BASIC can’t use all of the Z80 address space.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
Vorticon
Posts: 69
Joined: Tue Mar 01, 2022 1:14 pm

Re: REM Line length

Post by Vorticon »

roganjosh wrote: Fri Mar 11, 2022 10:13 pm
You can have a REM statement that fills up most of the available RAM. It'd obviously be tedious to type in though. I wrote a little assembler program a while ago where you're prompted for the number of reserved bytes you want and it produces a REM statement with line number '0' (which normally won't clash with existing lines and also is relatively safe from deletion) containing the required space. The source code is attached along with an assembled binary. It was written to be used under EightyOne so you load the binary in as a block at address 30000 and do a "RAND USR 30000" to start it. The assembly address was chosen arbitrarily. Obviously don't have the REM space ploughing into the machine code routine. You can also enter a hex value if the hex digits are preceded by a '$'.

Alan
Thank you! I'll see if I can adapt it to run on real hardware using er... a REM statement :lol:
I have to admit the Zeddy is a very peculiar machine, hence the attraction.
User avatar
kmurta
Posts: 305
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Re: REM Line length

Post by kmurta »

Vorticon wrote: Fri Mar 11, 2022 1:44 pm ... but doing assembly on the Zeddy hardware (not emulation) appears to be a particular form of masochism :lol:
I recommend using ZX Assembler 2 to minimize difficulties, although it has limitations if you are developing large programs. The ideal would be to have 8KB of RAM between 8192 and 16393 for the assembler and leave the 16Kb of RAM exclusively for the program under development. But with only 16Kb you will still have approximately 8Kb for your program, which I believe is enough for most needs. Take a look:

ZXASSEM2.zip
(1.48 MiB) Downloaded 83 times
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
User avatar
Vorticon
Posts: 69
Joined: Tue Mar 01, 2022 1:14 pm

Re: REM Line length

Post by Vorticon »

kmurta wrote: Sat Mar 12, 2022 1:40 pm
I recommend using ZX Assembler 2 to minimize difficulties, although it has limitations if you are developing large programs. The ideal would be to have 8KB of RAM between 8192 and 16393 for the assembler and leave the 16Kb of RAM exclusively for the program under development. But with only 16Kb you will still have approximately 8Kb for your program, which I believe is enough for most needs. Take a look:
This is excellent. Thank you.
I have a ZXpand (original version) which should make it easy to transfer the program to the computer. I'll probably also make a copy on physical tape in case my ZXpand fails.
Post Reply