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_40,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!rpi!think.com!spool.mu.edu!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: <1991Jun3.075741.1945@weyrich.UUCP> Date: 3 Jun 91 07:57:41 GMT Article-I.D.: weyrich.1991Jun3.075741.1945 References: <3949@titan.tsd.arlut.utexas.edu> <1991Jun2.095459.1@east.pima.edu> Reply-To: orville@weyrich.UUCP (Orville R. Weyrich) Organization: Weyrich Computer Consulting List-Id: In article <1991Jun2.095459.1@east.pima.edu> rharwood@east.pima.edu writes: >In article <3949@titan.tsd.arlut.utexas.edu>, >gardner@titan.tsd.arlut.utexas.edu (Don Gardner) 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. > >Well, it's been 2.5 years since I did this, but IMHO "the right way" to do what >you are trying is to encapsulate the READ operation in a FUNCTION and the WRITE >operation in a one-parameter procedure. Several replies to your message I have one concern about this approach: What happens if the compiler optimizer is SO CLEVER that it notices a write to a location that is never referenced, and optimizes away the write? Does anyone know of a compiler that is this clever? In any event, you had best check the machine language generated each time your compiler is upgraded ... Is there any issue pending before the 9x committee to address the issue of declaring certain memory locations as VOLATILE? -------------------------------------- ****************************** 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) -------------------------------------- ******************************