| |||||
Technical Support Support Resources
Product Information | A51: TABLES WITH CALCULATED VALUESInformation in this article applies to:
QUESTIONIs there an easy way in assembly to create a table of values that are calculated at assemble-time? ANSWERThere are several ways to do this. For tables that use values that are outside the range supported by the A51 assembler, you may create a table in C and generate assembler output. For example, the following C file:
#pragma SRC
#define DIVISOR 517
#define STEP 4165
code unsigned int J_TABLE [] =
{
(1 * STEP) / DIVISOR,
(2 * STEP) / DIVISOR,
(3 * STEP) / DIVISOR,
(4 * STEP) / DIVISOR,
(5 * STEP) / DIVISOR,
};
Generates the following .SRC file when compiled.
?CO?TEST SEGMENT CODE
PUBLIC J_TABLE
RSEG ?CO?TEST
J_TABLE:
DW 00008H
DW 00010H
DW 00018H
DW 00020H
DW 00028H
; #pragma SRC
;
; #define DIVISOR 517
; #define STEP 4165
;
; code unsigned int J_TABLE [] =
; {
; (1 * STEP) / DIVISOR,
; (2 * STEP) / DIVISOR,
; (3 * STEP) / DIVISOR,
; (4 * STEP) / DIVISOR,
; (5 * STEP) / DIVISOR,
END
Which you can either include in your assembler files or use as an external table. Last Reviewed: Thursday, January 18, 2001 | ||||
| |||||