ZX Format #03
29 февраля 1996
  Бейсик  

Programmers - Basic to all number 3.

<b>Programmers</b> - Basic to all number 3.
             BASIC.


               # 3


(C) Dm. Rudovsky 1996

________________________________



   This article focuses on
BASIC compilers.

   This section of the application is interesting because it 
can significantly increase the speed of BASIC programs and 
thereby removing one of the most severe restrictions BASIC -

slowness.

        ________________



   Compilers beysika on Spect
room can be divided into two

Groups:



   1. Compiler interprets the type. These compilers convert the 
program into a special code, intuitive control program, which 
is a simplified version built interpreter, due to which

there is gain in speed.

   However, code compiled
programs have in
BASIC program, or in the field
variables, which makes it impossible to create the overlay 
(nested) procedure. 

   2. Compiler translates
type. Compilers of this type
create a table of the addresses of routines and place the 
compiled program, usually at the address, but because of 
complication of the procedure compilation, take up more space 
and have more restrictions.



   Now, a brief description of the advantages and disadvantages 
of that and other types of compilers.



   Compilers of the first type, as
Typically, not only do not impose
restrictions on their use, but
and allow the funds to significantly expand the standard 
beysika. As an example can be reduced Laser Basic Compiler. In 
addition, they tend to use the same area as the standard

BASIC to store variables
that can be used without
additional complications to the treatment of non-standard 
variables and functions. 

   The disadvantages of this type, the compiler, except as 
specified above, may include more, and the impossibility of 
creating control program beysike and small

efficiency of the compilation of
volume and speed.

   To explain a little deviate from the topic: the 
effectiveness of volume - the ratio of the length of the 
program to compile to a size object module.


   Effectiveness of speed -
the ratio of run-time following the program to compile and 
after. 

   Here's the program:


  10 FOR I = 16384 TO 22527

  20 POKE I, 255

  30 NEXT I

  40 STOP


   Count the time from when you <ENTER> and before the onset of 
the inscriptions: 9 STOP statement, 40:1




   Well, it's time to go back to the compiler. The second type 
of compilers is also not ideal and

only its merits
are speed and portability of code, ie opportunity
compile almost to
anything and everything else - solid faults. There are more than
enough:

   First, the weight restrictions,
imposed by the compiler to
program: one does not "digest" command BEEP, another 
multi-dimensional arrays, the third general integer ...


   Secondly, because of the complexities
compilation significantly grows
"Load" (block codes, you must compile the program
for work.)


   Now more about the specific
compilers:



          The first type.


Optimizing compiler BLAST

(Must be provided for this


      with the utility TOOLKIT).



   Immediately should be noted that
this description is largely drawn on the basis of the book
"Handbook of System Software 48K" firm SOLON and more
from the above needs
experimental verification. Check all of the following on
practice, I could not because of
absence in my archives normally disketirovannoy version
BLAST'a.

   BLAST allows you to compile in immediate mode
program of not more than 3K.
At large sizes required
pretreatment program debugger TOOLKIT. The compiler accepts the 
following command: 


   * C - Compiling a program.

   * R - Start compiled

      program.

   * S - Record compiled
      th module to the disk.

   * I - Selecting the input memory device
      Islands to compile.

      R - memory;

      E - recorder;

      M - mikrodrayv.

   * O - Select output device
      properties (similar to the input)


   BLAST can significantly
extend the standard beysika, using the construction: REM option.


   Options:


   ! AUTORUN - Auto-compiled program after downloading;

   ! PCODE - Generation Secure Pi-code;

   ! MACHINE CODE - Generation
normal code;

   ! INT pairs. - Announcement of integer variables (take 2 
bytes instead of the usual 5); 

   % ... - Regular commentary;

   '& AmpBREAK (ON / OFF) - Enable /
disabling shutdown by pressing
BREAK.

   '& AmpWHILE condition - operator
cycle, familiar to many by language
Pascal, C. When the truth of the conditions the operator is 
passed, otherwise - Jumps to the statement following the '& 
ampWEND. 

   '& AmpWEND - acts like
GO TO '& ampWHILE and serves to indicate the end of the cycle 
WHILE ... WEND. 

   '& AmpREPEAT - on the operator, following this transition 
occurs with the statement '& ampUNTIL.


   '& AmpUNTIL condition - operator
similar '& ampWHILE, used
in the construction REPEAT ... UNTIL.


   A small deviation for those
who are not familiar with Pascal or C.

   In algorithmic languages ​​generally divided into two types 
of cycles: cycles and cycles with the precondition with 
postcondition. 

   Loops with a precondition ('& ampWHILE
... WEND), with an initial value
conditions - a lie, never satisfied. In contrast, the loops 
with postcondition (FOR. .. NEXT, REPEAT ... UNTIL) are 
performed at least once, even if the condition

false.


   '& AmpDOKE x, y - Version POKE, but
record in the x word (2 byte) y;

   '& AmpDEEK x, y - Function tantamount: Y = 256 * PEEK (X +1) 
+ PEEK (X); 

   '& AmpCALL x, [a, b, c ,...] - Calling
routines in machine code for
at x, with the transfer of the optional parameters a, b, c, ...
so that on the first of them indicates registry IX;

   '& AmpELSE operators - a very useful addition, there
virtually all versions of beysika and is used in the 
construction of IF ... THEN ... ELSE ..., where specifies what 
actions produce in the event of failure conditions after IF. 


   And a few more niceties:

   1. Likely BLAST hit
(Or fall) to you with the unwithdrawn
protection from this problem, we recommend to apply to the said
above the source.

   2. If you managed to compile your program in
BLAST'e, here is the method of unloading
program on tape (on disk as well?):

 15 LOAD "PROC"
 20 RANDOMIZE USR PEEK 23635 +

     256 * PEEK 23636 +150: SAVE

     "PROC" LINE 15


   3. Compiled module
works only if the
memory unit operating procedures RT
CODE.

   4. Compiler Features:
The coefficient of volume: 95%
Speed ​​ratio: 145%
Size of the "sample": 5K

! Program Description TOOLKIT
given in the second issue of the magazine.



   Compiler BASIC programs


     from the package LASER BASIC


     Company OASIS SOFTWARE.



   About this compiler says
many will not, because later, when
description of the LASER BASIC,
and tell them about the perceived
extensions.

   So take a CLEAR or 59799
below, we load the unit COMPCODE compiler and the program, then
run the compiler directive
RANDOMIZE USR 59800 and wait until
screen is cleared and will not appear
inscription, which, they say, all okay.
Then write a compiled program as a BASIC-block
but in any case do not make any
RUN, or CLEAR, because compiler
places the code in the field variables, and cleaning this area
will destroy the program.

   To run the program repeat the same steps, but instead
compiler will ship the package working
procedures - RTCODE. Running the program - GO TO 1.

   Compiler Features:
The coefficient of volume: 85-100%
Speed ​​ratio: 130-150%
Size of the "sample": 5.7K



    The second type of compilers.



        ZX COMPILER v1.0


      THRELFALL '& HODGSON.


           1982.



   This compiler is an integral
is probably the first of
compilers for Spectrum-BASIC. It is not the worst on
Today, though created by
3 years 2 version of the compiler, who lives in our country
under the name MCODER 2 works
somewhat faster. Since
talk about the limitations
the compiler is too long
I will say briefly - if some
design compiler does not accept, he will bring it to the screen 
and stop compilation. 

   To compile the necessary
lower the level of RAMTOP ADDRESS
COMPILATION-1 (the method is applied in all the compilers of 
the second type) and run the compiler command RANDOMIZE USR 
60000. 

   Compiler Features:

                  v1.0 v2.0
Coefficients. volume: 140-180%
Coefficients. speed: 2200% 2500%
Size of the "sample": 4.8K 4.8K



        INTEGER COMPILER


          Martin Lewis


            1983



   Martin Lewis in 1983 released a compiler for performance 
equal to ZX COMPILER v2.0, though, "Hitch" was

Long at 0.5K, but in the course of compiling the information 
displayed is less. 

   In the same year Lewis launches
and a compiler that works with floating point (fractional 
numbers). FLOATING POINT COMPILER occupied almost the same 
space as an integral and its sibling, however, performance fell 
in 6 times, so if your program does not use fractional numbers 
use This compiler is

ineffective.

   Both of these compiler run with the address 59300.

   Features FPC v1.0:
The coefficient of volume:> 150%
Speed ​​ratio: 400%
Size of the "sample": 5.3K



             TOBOS

 FULL FLOATING POINT COMPILER.



   Perhaps the most powerful
compiler of the second type. He
practically does not put restrictions on the compiled program.

   So, how to work with these
compiler:

  1. RAMTOP dip to the right
address, but not exceeding 50000.

  2. Download a compiler.

  3. Download the program you want to compile.

  4. Run the compiler directive RANDOMIZE USR 53100.

  5. Write the code block to
the compiler.


   The main drawback of this compiler - a huge amount of 
"sample", as well as clearing the entire memory module, and 
between skomplirovannym "hitch." 

   Compiler Features:
The coefficient of volume: 95-140%
Speed ​​ratio: 600%
Size of the "sample": 12.1K

! Warning:


   All the compilers of the second type

require the presence in memory CE
BOJ to normal operation compensated
lated program.



   P.S. All the compilers of both
types do not admit of the compiled program with I / O devices 
(tape drive), refer to them only from the machine code.

________________________________






Other articles:

IS-DOS - "IS-DOS - for beginners" No 3

IS-DOS - "Window System IS-DOS".

IS-DOS - "object module format *. obj IS-DOS assembly language."

IS-DOS - "The format of the table of local symbols IS-DOS assembly language."

Authors Journal - ZX-Format No.3

Iron - Bugfix TR-DOS.

Iron - a new sound card: General Sound.

Iron - a new model of the Spectrum: Scorpion ZS 256 Turbo +.

Iron - on turbirovanie Spectrum machines.

Iron - an overview of modems for the ZX Spectrum.

Iron - The bus architecture of the Spectrum (concept).

Toys - "Last battle" (The Last Stand) a detailed description.

Toys - 48 irons (second level).

Toys - a dozen of the most sold in St. Petersburg.

Toys - description of the game BATMAN-II.

Toys - What's new: The Light Corridor, Jonny Quest in Doctor Zins, Bedlam, Bubble Dizzy, Navy Seals, Pirates.

Contest - a competition for computer anecdote.

Lottery - a lottery for the readers.

From the authors - the third edition of the journal.

a rest - Hu, user, wait!

a rest - glyukodrom: Most ERRORS.

Help - Another treatise on ocherdnoy obolchka and beyond.

Mailbox - discussion.

Mailbox - Translator.

Mailbox - letters from readers.

Premiere - TASM 4.0 (Turbo ASseMbler for ZX-Spectrum 128k)

Premiere - The Adventures of Winnie the Pooh.

Programmers - Basic to all number 3.

Programmers - Matching games: the adaptation of programs to disk.

Programmers - Matching games: zykrytye codes.

Programmers - adapttsatsiya games: immortality.

Programmers - assembler: Excursion to the anatomy of the ZX

Miscellaneous - Amiga: questions and answers.

Miscellaneous - Amiga: news.

Miscellaneous - Prospects for P / O.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
TOP TEN - Desyatochka best games.
Humor - rules for using floppies.
Scene - thinking out loud: "Ha. And what if 'share ideas'? Forgive so - just language would scratch? I still paz povtopyayu something with which you do not upopno want to disagree do not know why: tvopchestvu HIKTO and HIKAKIMI thoughts will not help. "article from Manwe.
Exchange of experience - Finalization ZX-ASM v3.0 by Ivan Roshchina.

В этот день...   21 November