ZX Review #7-8-9-10
08 ноября 1997 |
|
Retro - 40 best treatments: Removal of REM-strings.
7.3. Removal of REM-strings Length: 132 Number of variables: 0 Checksum: 13809 Purpose: This program removes all comments from BEYSIKprogrammy. Subroutine call: RANDOMIZE USR address Error checking: If no-BASIC program, the procedure returns to BASIC without any action. Comment: The procedure ROM which is used to delete characters, is not running very quickly and therefore routine "removal REM-lines" running slow. LISTING machine code Assembly label number to VVODA147. LD HL, (23635) 42 83 92 JR CHECK 24 31 NEXT_L PUSH HL 229 INC HL 35 INC HL 35 LD C, (HL) 78 INC HL 35 LD B, (HL) 70 NXT_CH INC HL 35 LD A, (HL) 126 CP 33254 1933 JR C, NXT_CH 56250 CP 234 254 234 JR NZ, SEARCH 32 26 INC BC 3 INC BC 3 INC BC 3 INC BC 3 POP HL 225 DEL_L PUSH BC 197 CALL 4120 205 24 16 POP BC 193 DEC BC 11 LD A, B 120 OR C 177 JR NZ, DEL_L 32246 CHECK LD DE, (23,627) two hundred thirty-seven 91 75 92 AND A 167 SBC HL, DE 237 82 RET NC 208 ADD HL, DE 25 JR NEXT_L 24214 SEARCH INC HL 35 LD A, (HL) 126 CP 13254 1913 JR NZ, N_ENT 32 8 ENT_FD POP HL 225 ADD HL, BC 9 INC HL 35 INC HL 35 INC HL 35 INC HL 35 JR CHECK 24231 N_ENT CP 14254 1914 JR NZ, N_NUMB 32 7 INC HL 35 INC HL 35 INC HL 35 INC HL 35 INC HL 35 JR SEARCH 24,231 N_NUMB CP 33254 1933 JR C, SEARCH 56,227 CP 34254 1934 JR NZ, N_QUOT 32 8 FD_QT INC HL 35 LD A, (HL) 126 CP 34254 1934 JR NZ, FD_QT 32250 JR SEARCH 24,215 N_QUOT CP 58254 1958 JR NZ, SEARCH 32,211 LD D, H 84 LD E, L 93 FD_ENT INC HL 35 LD A, (HL) 126 CP 13254 1913 JR Z, ENT_FD 40209 CP 33254 1933 JR C, FD_ENT 56246 CP 234 254 234 JR NZ, N_QUOT 32236 LD H, D 98 LD L, E 107 DEL_CH PUSH BC 197 CALL 4120 205 24 16 POP BC 193 DEC BC 11 LD A, (HL) 126 CP 13254 1913 JR NZ, DEL_CH 32245 POP HL 225 INC HL 35 INC HL 35 LD (HL), C 113 INC HL 35 LD (HL), B 112 DEC HL 1943 DEC HL 1943 DEC HL 1943 JR CHECK 24160 Error control: if the number bytes to copy is 0 or the first line is already there, the program returns to BASIC. The program does not check if there is enough memory for the new line. The program requires 10 bytes per byte of data plus five bytes Line numbers, pointers length, etc. In addition, the used subroutine ROM also uses a large working area - take this into account. If the available memory is not enough, signs line will be installed correctly and BASIC listing is not reliable. Comment: The time involved in work of this program is proportional to the amount of memory for copying. LISTING machine code Assembly label number to VVODA147. LD DE, (23296) 237 91 0 91 LD BC, (23298) 237 75 February 1991 LD A, B 120 OR C 177 RET Z 200 LD HL, (23635) 42 83 92 LD A, (HL) 126 CP 0254 0 JR NZ, CONT 32 6 INC HL 35 LD A, (HL) 126 CP 1 254 1 RET Z 200 DEC HL 1943 CONT PUSH HL 229 PUSH BC 197 PUSH DE 213 SUB A 151 CALL 3976 205 136 1915 EX DE, HL 235 LD A, 1 January 1962 CALL 3976 205 136 1915 EX DE, HL 235 CALL 3976 205 136 1915 EX DE, HL 235 CALL 3976 205 136 1915 EX DE, HL 235 LD A, 228 62 228 CALL 3976 205 136 1915 EX DE, HL 235 NEXT_B POP DE 209 LD A, (DE) 26 PUSH DE 213 LD C, 47 14 47 HUNDR INC C 12 LD B, 100 6100 SUB B 144 JR NC, HUNDR 48250 ADD A, B 128 LD B, A 71 LD A, C 121 PUSH BC 197 CALL 3976 205 136 1915 EX DE, HL 235 POP BC 193 LD A, B 120 LD C, 47 14 47 TENS INC C 12 LD B, 10 June 1910 SUB B 144 JR NC, TENS 48250 ADD A, B 128 LD B, A 71 LD A, C 121 PUSH BC 197 CALL 3976 205 136 1915 POP BC 193 EX DE, HL 235 LD A, B 120 ADD A, 48 198 1948 CALL 3976 205 136 1915 EX DE, HL 235 LD A, 14 62 14 LD B, 6 6 6 N_ZERO PUSH BC 197 CALL 3976 205 136 1915 POP BC 193 EX DE, HL 235 SUB A 151 DJNZ N_ZERO 16247 POP DE 209 PUSH HL 229 DEC HL 1943 DEC HL 1943 DEC HL 1943 LD A, (DE) 26 LD (HL), A 119 POP HL 225 INC DE 1919 POP BC 193 DEC BC 11 LD A, B 120 OR C 177 JR Z, ENTER 40 10 PUSH BC 197 PUSH DE 213 LD A, 44 62 44 CALL 3976 205 136 1915 EX DE, HL 235 JR NEXT_B 24173 ENTER LD A, 13 62 13 CALL 3976 205 136 1915 POP HL 225 LD BC, 0 1 0 0 INC HL 35 INC HL 35 LD D, H 84 LD E, L 93 INC HL 35 POINT INC HL 35 INC BC 3 LD A, (HL) 126 CP 14254 1914 JR NZ, END? 32 12 INC BC 3 INC BC 3 INC BC 3 INC BC 3 INC BC 3 INC HL 35 INC HL 35 INC HL 35 INC HL 35 INC HL 35 JR POINT 24237 END? CP 13254 1913 JR NZ POINT 32233 LD A, C 121 LD (DE), A 18 INC DE 1919 LD A, B 120 LD (DE), A 18 RET 201 2 How it works: In a couple of registers DE loads the address of bytes to copy and a pair of registers loaded BC number of bytes to copy. If BC contains 0, the program returns to BASIC. In a couple of registers, the address is loaded HL-BASIC program. As the battery is loaded a byte from address specified in HL. This byte line number. If it is not 0, the first line of not exists and the program jumps to CONT. If the high byte contain 0, the accumulator is loaded least significant byte. If this value set to 1, the first line already exists and the program returns to BASIC. Address high byte numbers string is stored on the stack. Preserved the number of bytes to copy, then the address data. In battery is loaded 0 (high byte of a new line number). Caused by routine ROM, located at 3976, inserts the character with the battery, at the address set in the HL. In HL reduced the value stored at this before this operation. In a battery is loaded, and this value is inserted 3 times. The first unit - is the low byte line number the following two - the length of the pointer line. In the battery and then load the character code DATA and is value is entered in a row. Address of the next byte of data recovered from the stack and loaded into the DE. This itself bytes loaded into the accumulator and the contents stored in the DE again stack. The C-register is loaded value of 1 less than the code symbol 0. C-register is increased, and the B-register value is loaded 100. B-register is subtracted from the battery and, if the result is negative, the routine returns to HUNDR. B-register is added to the battery (so the battery has a positive value). This value is then loaded into the B-register. As the battery is loaded content C-register, and BC remains at stack. Calling routines ROM (3976), is inserted into the symbol that is stored in the battery, the address contained in the HL. BC register pair is recovered from the stack, and a battery load value B-register. The above-mentioned method is then repeated for the B = 10. Battery is then increased by 48 and the resulting character is inserted into the string. The above-described subroutine interpolate decimal representation occurs bytes Data in the expression of DATA. Now should be inserted into a binary representation. This value is marked with the code NUMBER (CHR 14), which is introduced first, followed by five zeros. The value of bytes copied is placed in a cell to replace third zero. DE increases pointing to the next byte of data. The number of bytes to copy is removed from the stack in the BC and this value decreases. If the result is 0, a transition is made to the ENTER, otherwise the contents register pairs BC and DE again pushed onto the stack, the expression DATA includes a comma, and the program returns to NEXT_B. This procedure code ENTER (End of line) is added to marking the end of the expression of DATA. In HL load address of the beginning line, and BC is set to 0. HL increased, indicating pointer to low byte strings, and this new address is copied into the DE. HL increased, pointing to the byte pointer line. HL and BC then incremented, and the battery is loaded symbol, located on address in HL. If the battery contains the code 14 - the number is found, the HL and BC increases by 5, jumping over the number and pointing to the character following behind him. Subroutine then proceeds to POINT. If the battery does not contain values of 14 and 13, the transition to a POINT. Completion of the formation line is executed by putting the contents of BC in the cell pointer string length. To the desired address points DE. At the end of of the procedure executes, returned to BASIC.
Other articles:
Similar articles:
В этот день... 21 November