Using the Hunter NVRAM Board

Author(s): P. Donnelly
Publication: LISTing Newsletter
Date: May - June 1985
Pages: 19

Oh yes! I’ve lent my Hunter Board to NAZIR for his bank switching experiments. This means I haven’t been able to actually use the loader program. I normally wouldn’t print a routine which I haven’t personally verified, but, as demand for these notes was urgent, here it is anyway.

* NVRAM MEANS NON-VOLATILE RANDOM ACCESS MEMORY

USING THE HUNTER NVRAM* BOARD

If you’ve bought and built Paul Hunter‘s NVRAM board, but are having some trouble moving your basic programs down into the 8-16K areas here is a little BASIC loader to set up the transfer program.

  1  REM XXXX This serves no function yet - make sure it has about 60 or 70 X's.
9 REM now we set up a numeric variable N
10 DIM N (45)
15 Print "ENTER THE NUMBERS TO BE POKED, WHEN PROMPTED"
20 For I =1 to45
25 REM Enter in the numbers from Hunter's table starting with 17 and ending with the 201 which
goes at 8289
30 Print "Memory Location"; 8243 + I;" will contain:";
40 Input N(I)
50 Print N(I)
60 Next I
70 Stop
100 REM now check your results
105 Print "I ";"I+8243";"Contents"
110 For I = 1 to 45
120 Print I;" ";I+8243;" ";N(I)
130
140 Print "If Some of These Are wrong, then correct them as direct statements. E.g., By
entering LET N(12)=33, if the code which was to go at location 8255 was not correct, etc."
190 STOP

200 REM now we do the actual Poking
210 For I = 8244 to 8289
210 Poke I, N(I-8243)
220 Next I
290 Stop
300 REM now new this Program out of existence
310 REM LOAD in your program (less than 6K, I hope)
320 REM and do A Rand USR 8244
330 REM A copy of your program will now reside
340 REM at location 9003 on your Hunter Board.
350 REM to Get it back, enter Rand USR 8269
Address   Data          Mnemonic
8244       17 125 64    LD DE (start of program area, 16509)
8247       42  12 64    LD HL (start of display file)
8250      183           OR A (clear carry flag)
8251      237  82       SBC HL, DE
8253       68  77       LD B, H and LD C, L
8255       33  40 35    LD HL (start of storage area; 9000)
8258      113           LD (HL), C
8259       35           INC HL
8260      112           LD (HL), B
8261       35           INC HL
8262       54 118       LD (HL), (code 118)
8264       35           INC HL
8265      235           EX DE, HL
8266      237 176       LDIR
8268      201           RETURN

Address   Data          Mnemonic
8269      237  75 40 35 LD BC (size of progam)
8273       42  12 64    LD HL (start of display file)
8276       43           DEC HL
8277      197 229       PUSH BC; PUSH HL
8279      205 158  9    CALL routine at 2462 decimal
8282      209 193       POP DE; POP BC (note exchange)
8284       33  42 35    LD HL (start of storage area; 9002)
8287      237 176       LDIR
8289      201           RETURN

Radio Electronics – Aug.’83

Enter the program as listed and then RUN it (only run this program once, unless you want to start over completely). You will enter the 45 machine code numbers given in Paul’s documentation for the board. The program will then list the numbers you typed in and the memory locations to which they will soon be POKE’d. To do this, GOTO 100. If some of the bytes are wrong you can change them by either re-running the program (to do them all over) or use a LET command as described in line 140.

Assuming all the values are correct, GOTO 300. The machine code necessary to transfer an entire BASIC program down to NVRAM and back again is now located in the NVRAM itself. Specifically, the transfer down routine begins at 8244 and the transfer back up routine begins at 8269. Your program itself will be put at location 9002 and those following.

The “power” command being used here is the LDIR at either 8266 (to transfer down) or 8287 (to come back). This machine language command transfers as many bytes as you want (e.g., length of program), from one part of memory (the BASIC area starting at 16509) to another (in this case from 9000 on).

Do note that the Real BASIC area and RAMPACK must be used to RUN a program, that is, you must move the program back to 16509 ff to use it. Also, and I had hoped most users realized this; the NVRAM occupies the space from 8-16K, thus, it is a maximum of 8K long. We’re using up the area from 8192 to 9000 for these and other routines. Therefore, the longest BASIC program, including saved variables, which can be placed in NVRAM is 16384 – 9000 or about 7300 bytes. So, if you have a program that is truly 16K – it just won’t fit. If your program is just a little too long, you can try compression techniques (e.g., delete all REMs, use variables (N=PI/PI for 1, etc, for numeric data) on your program before transfering it down.

HOW IT WORKS

Given that you’ve entered our program and Paul’s data correctly, the transfer code is ready and waiting down in the 8-9K area. To actually do your transfer do this:

1 LOAD the program you want to keep in NVRAM.

2 In the immediate mode, Peek 16404 + 256 * (PEEK 16405). This is E-Line, the end of the variable area. If this is greater than (16509 + 7300) 23800, or so, you have a problem and must reduce the size of the program or eliminate the variables.

3 Assuming your program is less than 7300 bytes long, now enter RAND USR 8244. A copy of your program now resides in NVRAM.

4 NEW your machine.

5 Now for the acid test. Press enter. No program there, right? Good! Now key in RAND USR 8269, and if all went well, your program is now back in the user area (16-32K) ready to run.

6 If you modify data, remember to SAVE a tape copy and transfer the new version down to NVRAM as in step 2 and 3 above. It will simply over-write the old version.

@ 1985 P. Donnelly


ZX-81 Pokes & Calls

Use at your own risk!

Rand USR 0        clears program & restarts
Rand USR 681      in FAST mode, prevents report code from display
Rand USR 757      in FAST mode saves a program without a name
Rand USR 836      in FAST mode, will load a program and STOP it even
                  if it is self starting. Gives a C error code but
                  disregard. Hit LIST and there is the program. Some MC
                  programs initialize from the print buffer and you may not
                  get a listing. I have seen only 1 program that did this
                  (HOT Z-1) Most start with a RAND USR 16514.
Rand USR 930      Equivalent to BREAK
Rand USR 963      clears program area & variables (NEW)
Rand USR 2955     equivalent to "," in a print statement
Rand USR 3086     scrolls up one line
Rand USR 3292     Equivalent to STOP
Rand USR 3875     Equivalent to FAST
Rand USR 3883     Equivalent to SLOW
Poke 16418, 0     Makes a 24 line display (don't scroll or input = CRASH)
Poke 16441, 20    Gives a 34 column display (careful, can cause CRASHES)
Poke 16509, N     N = 40 to 63. Makes editing hard; line # have letters.
                  N=99 prevents program from running or listing, poke to 0
                  to restore operation.
Poke 16510, 0     Makes first line number 0, can't be edited. Use for
                  Copyright notice. To hide listing use the following
Enter "1 REM aa", then POKE 16514,118 & POKE 16515, 118. Listing is gone

Capt Anthony J. Oresteen
[address omitted], FT Knox, KY 40121 [phone number omitted]

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.