RTC
®
4 PC Interface Board
Rev. 1.3 e
5 Advanced Programming
45
innovators for industry
5.6 Structured Programming
The command set of the RTC
®
4 includes a number of
list commands for controlling program flow:
• set_list_jump
• list_call
• list_call_cond
• list_jump_cond
• list_return
• list_nop
Together with the control commands
set_input_pointer and execute_at_pointer, this
allows structured list programming and execution.
Input Pointer
To write a list of commands to a particular location
in the RTC
®
4 list memory, the command
set_input_pointer (see page 106) is used
(instead of the commands set_start_list_1 /_2).
The command places the input pointer at any address
in the range [0 … 7999]. The next list command will
be written to this address.
The current position of the input pointer can be inter-
rogated by calling the command get_input_pointer
(see page 83).
List Jumps
The command set_list_jump (see page 109) defines
a jump to the specified address. During execution,
the RTC
®
4 jumps to this address.
Similarly, the command list_call defines a jump
to a subroutine (sub-list). The sub-list has to be
terminated with the command list_return.
The main list must be terminated with the command
set_end_of_list.
Conditional List Jumps
Conditional list jumps and subroutine calls can be
programmed via the commands list_jump_cond and
list_call_cond: The current value of the 16-bit digital
input port at the EXTENSION 1 connector is read and,
depending on its value, a subroutine is called or a
jump within a list is executed (also see "Programming
Examples", page 46 and "16-Bit Digital Input and
Output", page 56).
Output Pointer
To start execution at a particular address, the
command execute_at_pointer (see page 81) must
be used. The RTC
®
4 starts execution immediately.
Execution stops when a set_end_of_list command is
encountered. If the end of the list buffer is reached,
the RTC
®
4 continues at the address zero.
If the external start signal (see the section "External
Control Inputs", page 13) is used, the command
set_extstartpos_list (see page 105) allows definition
of the start address for the external list start.
• These commands use the RTC
®
4 list memory as
a single list buffer with a total capacity of 8000
entries. Each command in the list buffer has a
unique address in the range [0 … 7999].
Caution!
• If the end of the list buffer is reached during
writing of a list, the input pointer is reset to
zero, i.e. the next list command is written to the
address zero.
• Make sure not to overwrite any commands
which are still needed by your application.
Caution!
• If the end of the list buffer is reached during
execution (and if the last command is not a
set_end_of_list command), execution
continues at the address zero.