Download ETEC Assembler Reference Manual

Transcript
14. Structured Programming
14.6.2 The Constant Lookup Table Declaration
A constant lookup table can be called from many locations. Prior to being called, the
constant lookup must be declared, as follows.
extern ConstantLookup diob g_myTableLookup [256];
14.6.3 The Constant Lookup Table Call
In order to retrieve the value out of the array, a call must occur. The table call has the
following format.
seq <condition> <register> = :: <TableName>[p_31_24],
<MaybeFlush>.
The condition is the program flow conditional that controls whether or not a value is
actually retrieved from the table. The register parameter describes which register the
returned value will be placed and must match the table definition. TableName must match
the table name assigned to the table in the table definition.
ram
seq
alu
ram
p31_24 <- TableIndex.
sr = :: MyTableLookup[p_31_24], flush.
p = sr.
p -> Result.
The above example puts the third element from the g_myTableLookup table into the diob
register.
14.6.4 Conditional Execution
Because the table call consists of two sub-instructions, a call and a dispatch, the call can be
made conditional. All the Sequencer Sub-Instructions are available. In the following
example the diob register will be loaded with a value, but only if the sr register is non-zero.
// Test the diob register value
alu nil = diob, ccs.
// TableIndex is an 8-bit DATA RAM variable
ram p31_24 <- TableIndex.
seq if z then sr = :: MyTableLookup[p_31_24], flush.
page 96, Assembler Reference Manual
(C) 2007-2015
Freescale Syntax