RTC
®
5 PC Interface Board
Rev. 1.9 e
6 Developing User Applications
78
Subsequent Protection and Conversion of
Non-Indexed Subroutines
Non-indexed subroutines can be (directly) written
only to a list buffer area (“List 1” or “List 2”), but not
to the protected buffer area (“List 3”). There are
essentially two methods to subsequently assign
protection:
(1) Change the configuration:
The region of the list buffer in which the non-
indexed subroutine was written (in case this
region lies in the upper range of the memory) is
assigned to the protected buffer area via the
config_list command. Subroutines subsequently
protected in this manner remain non-indexed
(with unaltered memory addresses) and can, as
before, be called via the list_call command.
To enable non-indexed subroutines to be placed
in this manner in the uppermost range of the
memory, the corresponding memory area might
need to be temporarily assigned to the list buffer
via config_list prior to loading the non-indexed
subroutine.
(2) Converting to indexed subroutines:
A non-indexed subroutine can be referenced via
the set_sub_pointer command (the non-indexed
subroutine is thereby assigned an index and is
included in the management of indexed subrou-
tines). It can subsequently be copied as an
indexed subroutine to the protected buffer area
(“List 3”) via save_disk/load_disk (save_disk
automatically stores all indexed subroutines and
non-indexed subroutines subsequently-refer-
enced via set_sub_pointer onto on a PC storage
medium binarily, ordered by index
-
load_disk
copies all those subroutines from there to the
protected buffer area). A subsequent call via
sub_call along with the index results in invoca-
tion of the copy residing in the protected buffer
area rather than the original.
If you want to subsequently protect a non-indexed
subroutine – either via method 1 or method 2 – then
be aware that absolute jumps within and out from
the protected buffer area are not allowed (see
"Jumps", page 81).
Indexed subroutines subject to conversion
(method 2) must observe all programming rules
regarding indexed subroutines (see page 77).
Always try to use only one of the two methods in
order to avoid unintended data loss in the protected
buffer area via overwriting. If you begin working with
method 1 but later want to also use indexed subrou-
tines, then you should convert into indexed subrou-
tines all of the protected buffer area’s non-indexed
subroutines created with method 2 before you define
the first indexed subroutine via the load_sub
command.
When doing so, observe the following guidelines:
• If method 1 is used and you remove overwrite-
protection for a part of the protected buffer area,
then you risk overwriting indexed subroutines or
previously protected subroutines that might still
be needed.
• Non-indexed subroutines subsequently protected
with method 1 can under some circumstances be
unintentionally overwritten via a later load_sub
or load_disk command.
•The set_sub_pointer command links the
supplied index with the supplied start address
even if an indexed subroutine had already been
previously defined for this index. The original
indexed subroutine with this index is then no
longer referenced and no longer callable via the
index.
• If using method 2, you should use it fully. If the
set_sub_pointer command alone is executed,
then the subroutine will already be callable via
sub_call and its index, but the subroutine
remains unprotected against overwriting.
Protection is obtained only after the subroutine is
subsequently copied as an indexed subroutine via
save_disk/load_disk into the protected buffer
area. Likewise, the number of list commands in
the subroutine is included in the internal
management table only via save_disk/load_disk.
•The save_disk command ignores unreferenced
non-indexed subroutines, even those subse-
quently protected in the protected buffer area via
method 1. Be aware that they can be overwritten
in the protected buffer area via load_disk.
•The save_disk/load_disk command automati-
cally replaces unallowed commands (e.g.
set_end_of_list) with list_nop commands.
• Indexed subroutines repeatedly referenced with
copy_dst_src will be duplicated in the list buffer
via a subsequent save_disk/load_disk. This could
lead to buffer overflow in the protected buffer
area.