
CHAPTER 3 SAVING AND LINKING PROGRAMS
3-3
SAVING DATA TO FLASH EPROM
Additional data, such as strings and constants, can be
saved to U3 using a variation of the SAVE command.
Exactly how much memory you have depends upon how
many and how large of program(s) you have.
Flash sector size must be considered when saving. The
sector size determines the minimum write ar ea. Thus, if
you were to save just 1 byte, 128 (29C010A type) or 256
(29C040A) bytes w ill be written. All unwritten data is
saved as FFH.
Font are stored starting at address &AC00, segment 9.
This is above program area 1. If space is tight, consider
using a 512K Flash.
Chapter 5 treats saving data to RAM and Flash more
extensively.
INSTALLING 128K OR 512K FLASH
Socket U3 can hold a 128K or 512K Flash EPROM.
Perform the following steps to install a a new Flash:
1) Remove power from board and r emove existing
EPROM from U3.
2) Orient the new Flash so pin 1 is near the edge
of the board. Install the IC.
3) Set jumper W2 according to memory size:
W2[4-5] 128K (29C010A, 29C010)
W2[5-6] 512K (29C040A)
LINKING PROGRAMS
One CAMBASIC program can load and run another.
For example, the autorun program can, at some point,
run the program in Flash area 1, which can then call the
original one. Using this technique, you can have
program sizes of nearly 70K bytes using a 128K Flash or
245K using a 512K Flash..
This linking is intended to be called occasionally
(although we have run programs that have linked
millions of times). For example, the second pr ogram is
a set up and calibration routine. This will fr ee up ma in
program RAM for variables.
Linking in CAMBASIC is not threaded code. It does
replace one program with another while keeping
variables.
When developing programs and testing for linking, make
sure you save any changes to Flash before running. Any
changes in program length, especially the first (autorun)
one, can have adver se, strange, or disastrous results.
When you have saved the changes, press the reset button
to simulate an autorun. NEVER start with program 1
(LOAD 1) then have it load program 0.
There are other do’s and don’ts, precautions and
limitations to linking. They are discussed below.
Program size
The first (autorun) program run MUST be larger than
the second, linked program. This is because variables
and data are stored above the program. If the second
program was longer, it would wipe them out. To simply
increase program size, add co mments.
Multi-tasking
All multitasking (ON BIT, ON COM$, COUNT, etc.)
and interrupts are disabled and multi-tasking data cleared
(hash table is zeroed out) when a program is linked.
You must re-enable them in your code. The reason for
this is the operating system stores the address (not line
number) to execute. When you chan ge progr ams,
addresses change.
You can save some selected data by writing it to a
variable. For example, the current count can be saved
just before you LOAD 1 RUN. You will need to re-
enable the count when you enter the program.
DATA statements
Use RESTORE to reset the DATA statement pointer
every time you enter a program (if you are using DATA
statements).
Linking within the program
To link to another program , execute
LOAD n RUN
on its own line. Do not put any other code after it. Do
not make it as part of a conditional statem ent, as in
IF A = N THEN LOAD 1 RUN
If you link within a subroutine, DO..U NTIL, or
FOR..NEXT, execute EXIT CLEAR before LOAD.
.
.
2250 GOSUB 7000
Commentaires sur ces manuels