ZX Review #7-8-9-10
08 ноября 1997

Retro - 40 best procedures for: Search and replace strings.

<b>Retro</b> - 40 best procedures for: Search and replace strings.
  8.7. Search and replace string


  Length: 85

  Number of variables: 3

  Checksum: 8518

  Purpose: The program searches
character string in the BASIC program and makes the replacement 
of each found string thong to the next line the same length.


  Variables:

     Name: old data start

     Length: 2

     Cell: 23296

     Comment: The address of the first
byte replacement string.

     Name: string length

     Length: 1

     Cell: 23298

     Comment: The length of the replacement string.

     Name: new data start

     Length: 2

     Cell: 23299

     Comment: The address of the first
byte replacement string.

     Subroutine call:

     RANDOMIZE USR address

  Error control: if the length
line is 0 or BASIC program in memory is not, then the procedure 
returns immediately in BASIC.


  Comment: time
This program depends on the length
line and the length of the BASIC program.


   LISTING machine code
Assembly label number to VVODA147.


       LD IX, (23296) 221 42 0 91

       LD HL, (23635) 42 83 92

       LD A, (23 298) 58 February 1991

       LD E, A 95

       CP 0254 0

       RET Z 200

       DEC HL 1943
NEWLIN INC HL 35

       INC HL 35

       INC HL 35

       INC HL 35

       JR RESET 24 23
CHECK INC HL 35

       PUSH DE 213

       LD DE, (23627) 237 91 75 92

       AND A 167

       SBC HL, DE 237 82

       ADD HL, DE 25

       POP DE 209

       RET NC 208

       LD A, (HL) 126

       CP 13254 1913

       JR Z, NEWLIN 40233

       CALL 6326 205 182 1924

       JR NZ, COMPAR 32 8

       DEC HL 1943
RESET PUSH IX 221229

       POP BC 193

       LD D, 0 22 0

       JR CHECK 24226
COMPAR LD A, (BC) 10

       CP (HL) 190

       JR NZ, RESET 32 245

       INC BC 3

       INC D 20

       LD A, L 122

       CP E 187

       JR NZ, CHECK 32216

       PUSH HL 229

       LD D, 0 22 0

       AND A 167

       SBC HL, DE 237 82

       LD D, E 83

       LD BC, (23299) 237 75 March 1991

       INC D 20
NEXT_CHINC HL 1935

       DEC D 21

       JR Z, FINISH 40 5

       LD A, (BC) 10

       LD (HL), A 119

       INC BC 3

       JR NEXT_C 24247
FINISH POP HL 225

       JR RESET 24 215
2

  How it works:

  In IX load address of the replacement string. This value 
should be higher RAMTOP. In HL load address of the beginning of 
program area, and the battery loaded length of the string is 
copied to the E-register for further use in

program. If the string
is equal to 0, the program returns
in BASIC.

  Fits HL, indicating
at the next byte pointer BASIC-line, and done
transition to the RESET.

  The procedure CHECK HL increases, pointing to the next
symbol. DE stored in the stack and
loads the address of the variables. If HL is not less than
DE, program end is reached, and
after the restoration of DE from the stack the program returns 
to BASIC.


  In the battery symbol is loaded at the address in HL. If this
value is a sign of ENTER,
the program returns to NEWLIN.
If the battery does not contain
sign of NUMBER (character 14), made the transition to COMPAR, 
otherwise HL increases by 5, so that the HL

indicates the fifth byte of the found.

  The procedure for the RESET BC loaded the address for search 
strings. Register D is set to 0

to store the number of characters per line, found to
time. The program then returns to the CHECK.

  In the procedure COMPARE in the battery loaded character of 
the string pointed to a pair of registers, BC. If this value 
differs from the byte at the address in HL, program jumps to 
the RESET. BC increases, pointing to the next character in the 
string register D, the counter increases. If

This value is not equal to the length
line, the program returns to
CHECK.

  If the string is found, HL stored on the stack, so the 
program starts searching for the next case from this address. 
In DE load string length and this

value is subtracted from HL, giving meaning to one less
than the starting address. Length of the string and then loaded 
into the D to use it as a counter. In BC loads the starting 
address of the replacement string, and register D is increased. 
Register HL increases, pointing to the next cell and the 
counter decreases. 

  If the counter is 0, HL recovered from the stack and made the 
transition to the RESET for the next case. In battery loaded 
symbol, which indicates BC, and this value is placed in a cell 
at a HL. BC increases, indicating

the next character, and the program returns to NEXT_CHAR.






Other articles:

TR-DOS for beginners - The end.

Computer novella - Prince of Persia.

Computer novella - Laser team (the game Laser Squad).

Crossing Dragon - Game Rapscallion.

Crossing Dragon - Playing The Runes of Zendos.

Crossing Dragon - Playing The Saga.

Crossing Dragon - Game Witch's Cauldron.

Crossing Dragon - Create Adventyuru. Review of the editors.

Crossing Dragon - Create a dictionary to Adventyurnoy game.

Program, which we choose - The possible consequences of using undocumented commands.

Program, which we choose - About noticed irregularities in some programs and suggestions for future versions.

Program, which we choose - A proposal to all the authors of software, printers, memory dump. Programmers protect discs from being copied.

Program, which we choose - A few suggestions to improve the assembly.

Program, which we choose - Suggestions for refining ZX Word v2.5.

Program, which we choose - The "Spectrum emulator" v1.2.

Program, which we choose - What could want in a perfect assembly.

Retro - 40 best procedures: Copying data in memory.

Retro - 40 best procedures: Exchange token.

Retro - 40 best procedures: Determination addresses BASIC string.

Retro - 40 best procedures: Determination of the length of BASIC programs.

Retro - 40 best procedures: Determination of the amount of free memory.

Retro - 40 best procedures for: Search and replace strings.

Retro - 40 best procedure: Find the string.

Retro - 40 best procedures: Search for the string.

Retro - 40 best procedures: the list of variables.

Retro - 40 best procedures: an increase and up the screen.

Retro - 40 best treatments: Removal of REM-strings.

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

Expert Tips - Game Fredloader.

Expert Tips - Game Robin of Sherwood: The Touchstones of Rhianon.

Expert Tips - Game Scorpions: Die Machines.

Expert Tips - Game Terropods.

page iS-DOS - Description of system restarts IS DOS.

Forum - An algorithm for recognizing characters.

Forum - Time undocumented command processor Z80.

Forum - The concept of a high-color screen resolution.

Forum - A few Pokes to a game. Program Hacman96.

Forum - As for the new DOS and BIOS settings for the Spectrum.

Forum - Multicolor program on any computer model. Using the 2 nd screen Multicolor'a. Demonstration of the text. Electronic journals.

Forum - Project ZX Config.

Forum - Improve Art Studio. Ideas on file compression.

Forum - ZX Spectrum emulator for IBM. About the hexadecimal system. Program ZX-Stars. Oddities in the Elita

Forum - The effects on the curb and Multicolor.

reader-reader - ZX Spectrum 128 - new opportunities, new challenges.

reader-reader - With 'Light'. Spectrum and expert system.

reader-reader - The printer driver for the Scorpion.

reader-reader - Print numbers in different number systems.

reader-reader - Programming arcade game with scrolling screen.

reader-reader - The procedure for printing labels assembler XAS to monitor debugger STS 4.3.

Studies - attribute scrolling text. "Gasilka" screen. A simplified version of the procedure, "Curtain". Procedure is enriched with pictures. Procedure display images on the points.

Studies - Graphic effect "color bars".

Studies - Driver screen printing 64 characters per line.

Studies - Set of protective boot.

Studies - Address to the drive mode IM 2. Working with non-standard disc format.

Studies - Print the character, magnified by 8 times. The program "pouring" screen. The procedure for screen-saver on the points. Clear screen in Terminator'e. Search strings in memory. System character set conversion.

Studies - Program - cataloger of disks.

Studies - Program the output values of the amplitude channel music. coprocessor on the curb.

Studies - Program the output image.

Studies - The program plugs sprite.

Studies - Cleanup of the specified window screen.

Studies - The program sort the array in ascending order. The procedure for filling the screen specified attribute. Procedure display pictures. The effect of moving towards the stars. "Shower", coming from the upper left corner of the screen. The procedure of "shedding" pictures on the pixel lines. The program of "pulling" the picture at an angle of 45 degrees. Three procedures "Scroll".

Studies - The printing of numbers.

Studies - The procedure for drawing a character with attributes.

Studies - The procedure for display pictures. Fade-OUT effect (picture goes beyond the edge of the screen). Visual effect "Fountain." Fade-OUT effect, mimicking the TV off. Procedure "Ignition" pictures. The program continuously drawing a picture.

Studies - The procedure for drawing a line.

Studies - The procedure for making optimal symbol table.

Studies - scrolling lines of text in the specified window. Attribute scroller. Diagonal scrolling.

Studies - sprite scroller. Procedure display screen.

Studies - Short procedure indicating the amplitude channel music. coprocessor. Way to subtract a constant from a register pair HL.

Studies - The formula for calculating the day of the week.


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

Similar articles:
A Tangled Web - The third citywide poitovka.
From the Editor - somnenenie tselessobraznosti in the newspaper.
Demo party - OFFICIAL Paradox'99 results for the ZX Spectrum.

В этот день...   28 April