Retro - 40 best procedures: the list of variables.

ZX Review #7-8-9-10
    8.5. Listing

          variables


  Length: 94

  Number of variables: 0

  Checksum: 10295

  Purpose: This subroutine
is a list of names of all the variables available in this
currently in memory.

  Calling the program:

     RANDOMIZE USR address

  Error checking: If the variables in the memory is not, the 
program returns to BASIC. 

  Comment: This is a big help in debugging programs, 
particularly long and complex. 


   LISTING machine code
Assembly label number to VVODA147.


       RES 0, (IY +2) 253 203 2134

       LD HL, (23627) 42 75 92
N_VAR LD A, 13 62 13

       RST 16215

       LD A, 32 62 32

       RST 16215

       LD A, (HL) 126

       CP 128 254 128

       RET Z 200

       BIT 7, A 203 127

       JR Z, BIT 62 May 1940

       BIT 6, A 203 119

       JR Z, N_BIT 40 31

       BIT 5, A 203 111

       JR Z, STR_AR 40 9

       SUB 128 214 128

       LD DE, 19 17 19 0
PRINT RST 16215

       ADD HL, DE 25

       JR N_VAR 24225
STR_AR SUB 96 214 1996

       RST 16215

       LD A, 36 62 36
BRACK RST 16215

       LD A, 40 62 40

       RST 16215

       LD A, 41 62 41
POINT INC HL 35

       LD E, (HL) 94

       INC HL 35

       LD D, (HL) 86

       INC HL 35

       JR PRINT 24234
N_BIT BIT 5, A 203 111

       JR Z, ARRAY 40 19

       SUB 64 214 1964

       RST 16215
NEXT_C INC HL 35

       LD A, (HL) 126

       BIT 7, A 203 127

       JR NZ, LAST_C 32 3

       RST 16215

       JR NEXT_C 24247
LAST_C SUB 128214128
JUMP LD DE, June 17 6 ​​0

       JR PRINT 24211
ARRAY SUB 32 214 1932

       JR BRACK 24216
BIT 5 BIT 5, A 203 111

       JR NZ, JUMP 32243

       ADD A, 32 198 1932

       RST 16215

       LD A, 36 62 36

       JR POINT 24211
2

  How it works:

  Bit 0 bytes at 23612
reset to the characters that appear on print, appeared in
top of the screen. In HL load address of the variables. As the 
battery is loaded ENTER sign and the routine is called ROM, at 
16. In battery is then loaded

code space, and called again
the same routine ROM.

  As the battery is loaded bytes
the address in HL. If the value
this byte is equal to 128, the program returns to BASIC, because
reached the end of the field variables.

  If bit 7 of accumulator set to 0, the program continues
to BIT 5 because met a string variable or number, name
which consists of only one
letters. Verified 6-bit accumulator. If it is 0, a transition 
is made to N_BIT, because identified an array or a number, 
whose name more than one letter. If Bit 5 of the battery is 0,

program goes to STR_AR.

  The program reaches this point, if found variable
is the control variable
Cycle FOR / NEXT. In this case,
Battery subtracted 128 -
the result is the character code for printing. In a couple of
DE loads the number 19, indicating the following variable in the
are added to HL. Symbol in the battery is printed, DE
added to HL, and the program
returns to search for the next
variable N_VAR.

  If the program finds a string array (up STR_AR),
then subtracted from the accumulator
number 96, which gives the code name
found in the array. This value is printed using a sub-ROMs. Sign
dollar and the left parenthesis are printed, and the battery
loaded code right parenthesis.
HL increased, indicating
bytes containing the length of the array.
This value is loaded into the DE,
so that the addition of HL gives
address of the next variable. A transition is made to PRINT, 
where the right bracket prints and DE is added to the HL.


  The procedure is verified N_BIT
Bit 5 of the battery. If it is set to 0, ie a numeric
array, then a transition to
ARRAY. If it is set to 1,
is a numerical variable name
which is longer than one letter. Subtracted from the accumulator
64, and the resulting
symbol is printed. The program then executes the loop,
print each character who met as long as there is at least one 
character with bit 7 set to 1. From

code of last character
subtract 128, DE loaded offset for next variable, and the 
program jumps to PRINT.


  If the array is found, 32 is subtracted from the battery to
get the correct code, and a transition is made to find the 
brackets - BRACK.


  The procedure BIT 5, if found the number with a name that has
only one letter, programmb
back to JUMP.

  End of sub work when the meeting variables - string. Addition
32 to the battery provides the code for
printing. Finally, the battery is loaded character code
the dollar and made the transition to
POINT.