🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3377

Re: constant tables?

#3377
From: "Mark Morgan Lloyd "
Date: Fri, 15 Mar 1996 13:34
32 lines
1344 bytes
Please try to keep your lines a bit shorter :-)

> How do I make constant tables?
> 
> I write code for an embedded system. Lookup tables in ROM are a pretty 
> useful thing and I just couldn't find a way to do it.

Depending on your compiler, you may find the literal data being put in an 
unexpected segment, and then copied to a literal constant. It is 
sometimes easier to put this sort of thing into a fixed location in 
memory, accessed by an absolute variable.

> Did I miss something?
> 
> Something like
> [BEGIN EXAMPLE]
> VAR
>   myTable : ARRAY [0..9] OF CARDINAL = [0, 6, 2, 5, 1, 3, 4, 9, 8, 7];
> [END EXAMPLE]

Depends very much on the compiler. Under TopSpeed (which we use for 
embedded '386):

TYPE    tableType= ARRAY[0..9] OF CARDINAL;

CONST   myTable= tableType(0, 6, 2, 5, 1, 3, 4, 9, 8, 7);

Mark Morgan Lloyd
mark_tbu@cix.compulink.co.uk

[Opinions above are the author's, not those of his employers or 
colleagues]
Technical Details
Message-ID: <DoB9py.3s6@cix.compulink.co.uk>
Path: arc1-ca.pugleaf.net!cix.compulink.co.uk!usenet
References: <erico-1403961506370001@infinitehell.cnmat.berkeley.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2
Path: arc1-ca.pugleaf.net!cix.compulink.co.uk!usenet
From: mark_tbu@cix.compulink.co.uk ("Mark Morgan Lloyd ")
Subject: Re: constant tables?
Message-ID: <DoB9py.3s6@cix.compulink.co.uk>
Organization: KDG Mobrey Telemetry
References: <erico-1403961506370001@infinitehell.cnmat.berkeley.edu>
Date: Fri, 15 Mar 1996 13:34:46 GMT
X-News-Software: Ameol