From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.7 required=5.0 tests=BAYES_20,GAPPY_SUBJECT, INVALID_DATE,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!weyrich!orville From: orville@weyrich.UUCP (Orville R. Weyrich) Newsgroups: comp.lang.ada Subject: Re: Types defining h/w r/o or w/o registers Message-ID: <1991Jun1.083411.217@weyrich.UUCP> Date: 1 Jun 91 08:34:11 GMT References: <9105311025.aa04299@PARIS.ICS.UCI.EDU> Reply-To: orville@weyrich.UUCP (Orville R. Weyrich) Organization: Weyrich Computer Consulting List-Id: In article <9105311025.aa04299@PARIS.ICS.UCI.EDU> Jose Aleman Duarte writes: >> Is there some way to define a type such that all variables of that >> type can be only read or only written? For instance, I have a type that >> defines the status register of some peripheral which can only be >> read. It would be best if the compiler could flag any assignments >> to variables of such a type as errors. > >> Is there some other means for commonly handling this problem? The >> compiler being used is VADSWorks, if an implementation-defined solution >> is required. > >Alternatively, you can define a "type" and then define a constant variable >of that type for read only variables... > >subtype XYZ is INTEGER; >NY_REG: constant XYZ := 0; -- define a variable that can only be read > NO NO NO! The original poster wants to describe a memory location that can be modified by an entity outside the control of the program. In C (and many DEC language extensions) this would be a VOLATILE memory location. If you tell the compiler that it is constant, the optimizer may copy the value into a register and use the copy, or do constant folding and substitute the value 0 for the memory reference. Can you say BUG? :-) -------------------------------------- ****************************** Orville R. Weyrich, Jr., Ph.D. Certified Systems Professional Internet: orville%weyrich@uunet.uu.net Weyrich Computer Consulting Voice: (602) 391-0821 POB 5782, Scottsdale, AZ 85261 Fax: (602) 391-0023 (Yes! I'm available) -------------------------------------- ******************************