ZX Format #04
14 июня 1996
  Бейсик  

Programmers - learn BASIC (Part 4).

<b>Programmers</b> - learn BASIC (Part 4).
             BASIC

              (# 4)

(C) Dm. Rudovsky
________________________________


   Basic, as well as all high-level languages ​​has several 
drawbacks. And most important of them - the slowness.


   Here is a simple example. Type in the program:


  10 FOR I = 0 TO 65535

  20 NEXT I

  30 CLEAR 29999

  40 PRINT "STOP TIME"

  50 FOR K = 30000 TO 30009

  60 READ B: POKE K, B

  70 NEXT K

  80 STOP
 100 RANDOMIZE USR 30000
 110 GO TO 30
 120 DATA 1,255,255,11,120,177
 130 DATA 194,51,117,201


   Run it with the command RUN,
count the seconds until the caption STOP TIME. Now run
program again, but this
RUN command 100 times, spending
similar operations.

   Now compare. As a rule,
the first result of a hundred times greater than the second. 
For those who do not understand, explain: first run -  
Basic-interpreter "running off"  empty cycle of 65,536 
times a second once the same has been made of

machine code.

   So, you find that the Basic
too slow. What do you do if your knowledge of assembly language 
does not allow you to create in him any masterpiece? The answer 
is simple: it is necessary to combine Basic features speeds

assembler.

   Remembering the last article, you
exclaim "Eureka!" and starts to search for the compiler, but 
after reading its description, come to the conclusion - "For a 
calculator can be fit. "


   Still, do not rush to read the section on the assembler, and 
continue reading until the end of this story, so as we are in 
it will just about the problem described above.


   The function returns the number of USR
the contents of register pairs BC,
remaining there after the
routines in machine code,
located at the address specified as a function parameter.

   The question arises - is it
basic procedures, such as
scrollbars will have to write myself?

   Of course, it makes no sense to reinvent the wheel - 
Elementary program has already been invented, written and 
compiled in the library under title:


    SUPERCODE and NEWSUPERCODE.

   All you need is
find the desired procedure, burn it to disk and insert it into
their program. How do these three points and go
it in the future.


   Describe the routines in these
packages, I'll order their numbers in Supercode 3.5, giving a
parentheses the number of the
procedures Newsupercode. But before that I have a few words
say about the control system
these packages.


   Supercode 3.5:

   This package consists of two
parts (sub 1-74, 75150). After downloading and introductory
words in Polish you will enter
menu. Dame transcript items
koi selected by pressing the first
letters of the team. From the outset,
You lurks a strange line at the bottom of the screen:


  DEMO / PRNTR / QUIT / ANY OTHER KEY

where DEMO - to demonstrate the possibilities of the program as 
a whole,  PRNTR - printing on a printer

 QUIT - exit in Basic,
 ANY OTHER KEY - continue.


   Continuing, we find ourselves in
Main menu:

 NUMBER - description of the procedure with
number, which you will be asked
enter.
 DEMO - see above.
 PRNTR - see above.
 LOCATE - explaining how to use the procedure at the addresses
different from those given in
Supercode.
 INDEX - page back.
 JUMP PAGE # - Go to page n (1-4).
 CONTINUE - to the next
page.
 SAVE - you write the correct routines on the disc.
 QUIT - see above.


   Pressing the "N" and typing in your desired
number of routines, you will see
its description and the next menu:

EXAMPLE / PRNTR / QUIT / ANY OTHER KEY


   Of all the new items only
a - EXAMPLE. For slightly familiar with English explaining -

  EXAMPLE - example
This means that by choosing this
point you will see an example of
This subroutine.


   Package Newsupercode different
from Supercode only fewer routines and the best
interface. Here the choice is made only arrow keys and "ENTER". 
Select the desired procedure to direct the cursor on it and 
press "ENTER". 


   Now we turn directly to subroutines themselves. I
give an example of working with them.

   So you want to in case of an error, not falling out in the 
Basic with no one needs an inscription, and the transition to 
line of your program where you analyze it.


   We'll see what to us for this
need:

 1. Sub-intercept errors.
 2. Sub-alarm went off.


   Now load and Supercode
looking for a subroutine with the number 65.
After running it for any termination of the program (even DC)
management will be transferred to
a line Basic program, whose address is given
us in the memory cells 60878/79.
Using the option SAVE write
this procedure on the disc. If
You have a cassette version, then write down on paper, address 
and length of this routines, and by pressing QUIT, quit in 
Basic. Write it in the usual way and then come back in the 
package command GO TO 0 and repeat the above manipulation 
procedure number 42. 

   Now, coming out in Basic, type out the program:


  10 CLEAR 60825

  20 RANDOMIZE USR 15619: REM:

     LOAD "65" CODE

  30 RANDOMIZE USR 15619: REM:

     LOAD "42" CODE

  40 POKE 63951,20

  50 RANDOMIZE USR 60826

  60 INPUT "INPUT N (1-5):"; N

  70 RESTORE: LET SUM = 0

  80 FOR I = 1 TO N

  90 READ A
 100 LET SUM = SUM + A
 110 NEXT I
"120 PRINT" SUMMA "; N;" NUMBER

     = "; SUM
 130 GO TO 60
9495 LET A = USR 63950
9500 LET A = PEEK 23681
9510 IF A = ​​CODE "E" THEN GO TO

     9700
9520 PRINT "ERROR, CODE"; A
9530 GO TO 1960
9700 PRINT "READ TEXT, PIG!"
9710 PRINT "EXIT?"
9720 LET K $ = INKEY $: IF K $ = ""

     THEN GO TO 9720
9730 IF K $ = "D" THEN LET A = USR 0
9740 IF K $ = "N" THEN GO TO 60
9750 GO TO 9720


   Some explanations. In line
40 set duration
audio signal in line 50
routine is activated to intercept errors, line 9495,
where the transition occurs after
Error, the buzzer sounds.

   If you are not satisfied with this
method, then wait for the next article
which will explain what to do
when the capabilities of the standard
Basica do not satisfy you.






Other articles:

Toys - 48 irons (3 levels).

Toys - the passage of La abadia del crimen.

Toys - short story of the game "Adventures of Winnie the Pooh" (Level 1)

Programmers - learn BASIC (Part 4).

Programmers - Adapting programs for TR-DOS # 2.

Programmers - IMMORTAL # 2 (immortality in the games).

Programmers - music editors, which we choose.

Programmers - Guide to shadow service monitor Scorpion ZS 256.

Programmers - "IN SEARCH OF ETERNAL LIFE."

IS-DOS - Category "IS-DOS - for beginners" No 4.

IS-DOS - users "No4:" Working with electronic drive among the IS-DOS ".

IS-DOS - information about the company ISKRASOFT.

Iron - Nemo responds to users' questions.

Iron - Message from the firm Nemo (about microprocessors Z84C0010PEC).

Premiere - Assembler, which we choose (a description of XAS).

Premiere - Program Description 'CONVER-Commander V 4.50 pro'.

Premiere - UFO-2. Devils pit.

Presentation - Novgorod Group Digital Reality about yourself.

Interview - Interview with Captain Nemo with comments Iskrasoft firm.

Interview - Nikolay Rodionov and ZX-Sectrum.

Interview - an interview with the developer of computer HOBBIT Dmitry Mikhailov.

a rest - HAL 9000

a rest - Nemo tells the story of VirtualETnoy reality in Russia.

Mailbox - letters from readers.

Mailbox - Translator.

Mailbox - "Empire Spectrum".

Miscellaneous - The introductory story to the game Paradise Lost (Lost Paradise).

Miscellaneous - Perspectives P / O: WARCRAFT

Miscellaneous - Amiga Club: Questions and Answers # 2.

Miscellaneous - Amiga Rulez or propoganda healthy lifestyle.

From Writers - a new issue and plans for the future.

Authors Journal - ZX-Format No.4

Lottery - the first results of the first lottery.


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

Similar articles:
Programmers - Matching games: zykrytye codes.
Nove!? - About the programs: Fifteen's, Reckless Rufus, Peking, Smagli-2.
Miscellaneous - a hooligan calls.
Ads - Advertisements and announcements ...

В этот день...   3 May