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

Retro - 40 best procedures: Search for the string.

<b>Retro</b> - 40 best procedures: Search for the string.
       8.6. String Search


  Length: 155

  Number of variables: 2

  Checksum: 17221

  Purpose: This program searches through the BASIC program and 
writes each line, containing a set of characters defined by the 
user. 

  Variables:

     Name: data start

     Length: 2

     Cell: 23296

     Comment: The address of the first
bytes of data.

     Name: string length

     Length: 1

     Cell: 23298

     Comment: The number of characters per line.

     Calling the program:

     RANDOMIZE USR address

  Error checking: If no BASIC program or a character string has 
zero length - return to BASIC.


  Comment: time
This program is proportional to
two quantities: the length of the string
variable-length-BASIC program. Search term must
be placed in the cell above
RAMTOP, and the address of the first byte
line should be placed in
23,296 cells / 7. String length
should be kept in a cell
23298.


   LISTING machine code
Assembly label number to VVODA147.


       RES 0, (IY +2) 253 203 2134

       LD IX, (23296) 221 42 0 91

       LD HL, (23635) 42 83 92
RESTAR LD A, (23 298) 58 February 1991

       LD E, A 95

       CP 0254 0

       RET Z 200

       PUSH HL 229
RESTOR PUSH IX 221229

       POP BC 193

       LD D, 0 22 0

       INC HL 35

       INC HL 35

       INC HL 35
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

       JR C, ENTER 56 4

       POP HL 225

       RET 201
LONG_J JR RESTAR 24223
ENTER LD A, (HL) 126

       CP 13254 1913

       JR NZ, NUMBER 32 5

       INC HL 35

       POP BC 193

       PUSH HL 229

       JR RESTOR 24221
NUMBER CALL 6326 205 182 1924

       JR NZ, COMPAR 32 8

       DEC HL 1943
DIFFER PUSH IX 221229

       POP BC 193

       LD D, 0 22 0

       JR CHECK 24216
COMPAR LD A, (BC) 10

       CP (HL) 190

       JR NZ, DIFFER 32245

       INC BC 3

       INC D 20

       LD A, D 122

       CP E 187

       JR NZ, CHECK 32206

       LD A, 13 62 13

       RST 16215

       POP HL 225

       PUSH HL 229

       LD B, (HL) 70

       INC HL 35

       LD L, (HL) 110

       LD H, B 96

       LD DE, 1000 17 232 3

       LD A, 47 62 47
THOUS INC A 60

       AND A 167

       SBC HL, DE 237 82

       JR NZ, THOUS 48250

       ADD HL, DE 25

       RST 16215

       LD DE, 100 17 100 0

       LD A, 47 62 47
HUNDR INC A 60

       AND A 167

       SBC HL, DE 237 82

       JR NC, HUNDR 48250

       ADD HL, DE 25

       RST 16215

       LD DE, 17 October 1910 0

       LD A, 47 62 47
TENS INC A! 60

       AND A 167

       SBC HL, DE 237 82

       JR NC, TENS 48250

       ADD HL, DE 25

       RST 16215

       LD A, L 125

       ADD A, 48 198 1948

       RST 16215

       POP HL 225

       INC HL 35

       INC HL 35

       INC HL 35
140.
NEXT_C INC HL 35

       LD A, (HL) 126
LINEND CP 13254 1913

       JR NZ, CHR_14 32 4

       RST 16215

       INC HL 35

       JR LONG_J 24155
CHR_14 CALL 6326 205 182 1924

       JR Z, LINEND 40243

       CP 32254 1932

       JR C, NEXT_C 56237

       RST 16215

       JR NEXT_C 24 23
2

  How it works:

  Bit 0 bytes stored in
at 23,612, dropped to the characters that appear in print,
appears at the top of the screen. In IX load address of the 
first byte of data. This allows you to load the address to 
another pair of registers, using less printer buffer.

In HL load address of the beginning
BASIC program.

  As the battery is loaded length of the reference line and the 
value is copied to the E-register. If string length is 0, the 
program returns to BASIC. Address in the HL

pushed onto the stack, holding the position of the unknown at 
the moment strings in memory.


  Address data is copied from the IX
in BC for greater accessibility. In
D-register is loaded 0, ie
number of found characters
equivalent entered data.
A pair of registers increases HL
3, indicating the high byte
pointer to the string length. HL increased, pointing to the 
next character. A pair of registers, DE stored in the stack.


  In DE loads the address of the variables, and this value is 
subtracted from the HL. If the result negative, the program 
goes to ENTER after the restoration of HL and the return of the 
stack DE. If the result was positive, the stack is restored

to its original size and return to BASIC, because reached the 
end of BASIC program. 

  The procedure ENTER in the battery loaded byte is stored at 
the address in HL. If it is not sign ENTER, the transition to a 
NUMBER. If the trait ENTER found, HL increases, pointing to the 
next line. Address of the previous row is removed from the 
stack and replaced with a new value in HL. Then becomes

transition to RESTOR. The procedure
NUMBER routine is called
ROM, which is located there at 6326. If the battery symbol is a 
sign of NUMBER (CHR_14), HL increases, pointing to the first 
character after pyatibaytnogo number representation, certain 
routine ROM. If the sign of NUMBER is not detected, the program 
goes to COMPAR, otherwise HL decreases

program goes to DIFFER. BC
copied from IX, the number of
characters found dumped
to 0 and a transition is made to CHECK.

  The procedure COMPAR in the battery loaded byte is stored at 
in BC. If this is not the same thing as byte is stored at the 
address in HL, the program returns to DIFFER.


  BC increases, indicating
the next byte of data, and the amount of certain characters
increases. If this value is not equal to the length of a 
character line, the program returns to

CHECK.

  As the battery is loaded code
sign ENTER, and this value
prints, using
RST command 16. Address Line
print boots from
stack in the HL. Line number and then
copied to the HL through the B-register.
In the DE 1000 and loaded into the accumulator value is loaded 
on 1 less than the character code 0.

Battery decreases, and DE
again subtracted from HL as
long as the HL does not become negative. Then DE is added to the
HL, to obtain a positive
residue. Symbol of the battery
printed.

  The above method is repeated and then to 100 and DE = DE = 
10. The residue was then loaded into the battery, added 48, and 
as a result of the symbol is printed. 

  Address of the start line is restored from the stack and 
loaded in HL. Then HL is increased,

pointing to a byte pointer to the string length, HL increased, 
and the byte address in HL loaded into the accumulator. If

This byte is not a sign ENTER, a transition is made to
CHR_14, otherwise ENTER displayed on the
printing. HL increases and the program returns to RESTAR.

  The procedure is called CHR_14
ROM routine at 6326.
If the battery symbol is a sign of the number, HL increases, 
pointing to the first symbol appearing after the found number. 
This character is loaded into the battery, and a transition is 
made to LINEND. Then, if the character in the accumulator has 
the code less than 32, the subroutine

returns to NEXT_C. If the code is
more than 31, found the symbol is printed and proisodit 
transition to NEXT_C. 






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:
Advertising - Advertisements and announcements ...
all of us - On the politeness: criteria-mannered person.

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