ZX ideas - Right-Aligned Text in BASIC and Machine-Code Program Renumbering for ZX Spectrum

ZX Revija #03

ZX Curiosities

A) Right-aligned Text

If you write some text on the screen, you can easily align it to the left margin using a simple command. However, if you want the text to be printed aligned to the right margin, you have to think of a trick to do it. Here is a BASIC routine that solves the problem:

1 INPUT "NUMBER OF TEXTS=";N
2 INPUT "POSITION OF LAST CHARACTER=";L
3 FOR I=1 TO N
4 INPUT ("ENTER TEXT:";I;");A$
5 LET P=L-LEN A$
6 PRINT TAB P;A$
7 NEXT I

You can use this routine in any of your programs. The core of the routine is lines 5 and 6. The other lines simply supplement them for demonstration purposes.

Just be careful not to use the variables used here in the rest of your program, as this could cause the main program to malfunction.

In this routine, they will probably take on different values, and after returning from the subroutine may cause unexpected consequences if you are not careful.

B.J.

B) Machine-code RENUMBER Routine

This routine is very short and simple.

It cannot renumber the arguments after the GO TO, GO SUB and RESTORE commands.

It is relocatable, so you can load it anywhere in the computer’s memory.

The routine is given first in DECIMAL form and then in ASSEMBLER form. You can use a simple LOADER or ASSEMBLER to enter it.

DECIMAL FORM              ASSEMBLER FORM
65000                     LD HL,(23635)
65004                     LD BC,10
65007                     LD DE,10
65010                     PUSH DE
65011                     PUSH HL
65012                     LD DE,(23627)
65016                     XOR A
65017                     SBC HL,DE
65019                     POP HL
65020                     POP DE
65021                     RET Z
65022                     PUSH BC
65023                     LD (HL),D
65024                     INC HL
65025                     LD (HL),E
65026                     INC HL
65027                     LD C,(HL)
65028                     INC HL
65029                     LD B,(HL)
65030                     INC HL
65031                     ADD HL,BC
65032                     EX DE,HL
65033                     POP BC
65034                     ADD HL,BC
65035                     EX DE,HL
65036                     JR ADDR+10

Before starting the program, set the step at address 65005/6 and the initial renumbering number at address 65008/9.

The routine has been set to use 10 for both arguments. Start it with:

RANDOMIZE USR 65000

B.J.

C) Viruses

Viruses are programs found on some infected floppy disks. They activate at a certain time and mess up your whole system. Usually, a virus is transferred from an infected disk into memory or onto a HARD DISK.

It can at least be removed from a hard disk, but removing it from memory is very difficult.

Once it has been loaded into memory, it keeps copying itself onto the next disk as well. In the beginning, one of the best-known viruses was the Friday the 13th virus, which activates on that day and destroys the data entered up to then (for example, data that had been entered over four years was destroyed in V.B.).

According to the latest information, there are more than 3,000 different viruses (programs for making junk on PCs). Protection against infection is a SCAN program, which detects viruses before you start using a disk on your PC. It is used to check whether a disk is infected and warns you. If you do not have a VACCINE to remove the virus, it is best to throw such a disk away.

Virus-removal programs are very expensive, and there is no guarantee that they can remove every virus, since your computer may be infected with some new virus. But let’s leave viruses and PC computers aside, since that is their problem, and let PC magazines deal with it.

For now, not a single virus is known to exist for the Spectrum, so we do not have to worry about our DUGA.

č.S.

D) THE GOLDEN AGE OF THE RAINBOW

It all began not so long ago, in 1980, when former journalist and failed entrepreneur Clive Sinclair launched the first British home computer, the ZX-80. More precisely, it was launched by his company, Science of Cambridge, known for manufacturing inexpensive HI-FI systems. It cost less than 200 pounds, about 8,000 dinars at the time. It looked very much like a real RAINBOW.

It ran on the ZX-80 microprocessor, replacing a heap of chips with a ULA chip. The ROM-BASIC had been expanded to 8K, and it could calculate decimal numbers.

It had 1K of RAM, expandable up to 16K.

It displayed 22x32 characters on the screen and used the Inter Basic language.

This computer, together with a cassette recorder and a television, could be called the first home microcomputer system. And so began the golden age of the RAINBOW.

In 1981, the ZX-81 computer was released under the new name of Sinclair’s company, Sinclair Research.

It measured 17.5x16.5 cm, and its keyboard measured 16x6.5 cm.

It was black and had 40 keys (4x10). It used the principle of one key—one command, but ENTER was called NEW LINE. It also ran on the ZX-80 processor. It had only 1K of RAM and 16K of ROM, which was already an improvement.

The option to expand the RAM to 16K remained.

It could be connected to a cassette recorder. The screen remained the same (22x32), but it now ran Sinclair BASIC. It could also be connected to a printer.

At first, it cost less than 200 pounds, while near the end of its run, a model with 16K of RAM cost 80 DM. Finally, let us mention the characteristics of Sinclair’s computers: small dimensions, made of plastic and rubber, and, most importantly, low prices.

Because of their low price, Spectrums (at least the first versions) had no interfaces except the general-purpose one, and their keyboards were sticky, made of paper and plastic, with rubber keys.

For his first computers, Clive claimed that they could control a nuclear power plant. In principle, he was right, because access to all their processor functions was available through the general-purpose interface.

That’s all for now. Until the next issue!

č.S.

Share your thoughts about the article