Retro - 40 best procedures: Remove the block of the program.

ZX Review #7-8-9-10
 7. PROCEDURES FOR PROCESSING PROGRAMS


  7.1. Removing the block program


  Length: 42

  Number of variables: 2

  Checksum: 5977

  Purpose: This program removes the block BASIC-programs, which 
lies between the lines defined by the user. 

  Variables:

     Name: start line no

     Length: 2

     Cell: 23296

     Comment: The number of first
lines to be removed.

     Name: end line no

     Length: 2

     Cell: 23298

     Comment: The last line number to be removed.

  Calling the program:

     RANDOMIZE USR address

  Error control: if they have
The following errors, then the procedure stops without deleting 
rows BASIC-programs: 

  - If the last line number
less than the first line number;

  - If between the two strings have a program in BASIC;

  - If one line numbers
or both are 0.

  Comment: This program is rather slow to remove
a large block of software
lines, but, nevertheless, to work with it still more convenient 
than deleting rows manually. 

  Do not enter a line number greater than 9999.


   LISTING machine code
Assembly label number to VVODA147.


        LD HL, (23296) 42 0 91

        LD DE, (23298) 237 91 February 1991

        LD A, H 124

        OR L 181

        RET Z 200

        LD A, D 122

        OR E 179

        RET Z 200

        PUSH DE 213

        CALL 6510 205 110 1925

        EX (SP), HL 227

        INC HL 35

        CALL 6510 205 110 1925

        POP DE 209

        AND A 167

        SBC HL, DE 237 82

        RET Z 200

        RET C 216

        EX DE, HL 235
NXT_CH: LD A, D 122

        OR E 179

        RET Z 200

        PUSH DE 213

        PUSH HL 229

        CALL 4120 205 24 16

        POP HL 225

        POP DE 209

        DEC DE 1927

        JR NXT_CH 24243
2

  How it works:

  In a pair of registers HL and DE are loaded starting and 
ending row numbers, respectively. These

values ​​are checked and, if one or both of them equal to 0, 
the program returns to BASIC. 

  It then calls the subroutine
ROM at 6510 - it returns the address in memory,
with which to begin the first
line. The same routine is then called again to determine the 
address character, standing ENTER after the final string.


  In a couple of registers placed HL difference between these 
two addresses, and If this value is 0 or

negative, the program returns to BASIC.

  The contents of register pair HL
copied to the DE for use DE as a counter. If
count is 0, then the work procedure is completed, and if not,
a routine is called ROM
located at 4120,
which deletes a single character.
After that - back to NXT_CH.