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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Clubley Newsgroups: comp.lang.ada Subject: Re: Representation clauses and side-efects on STM32F411 ravenscar runtime Date: Mon, 3 Aug 2015 11:08:55 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <55bddbe2$0$3384$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 3 Aug 2015 11:08:55 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="81f6a8df16d75c949ed414fa5d329330"; logging-data="19750"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1832hQXbb5w5jUbw+/EUNGAS3xgr09x/WY=" User-Agent: slrn/0.9.9p1 (Linux) Cancel-Lock: sha1:CIH9+aVGXLge69sXAihrWcsYuYY= Xref: number.nntp.giganews.com comp.lang.ada:194648 Date: 2015-08-03T11:08:55+00:00 List-Id: On 2015-08-02, Frédéric Praca wrote: > For example, with the following declaration: > > type Mantissa is range 0 .. 2**12 - 1 with Size => 12; > type Fraction is range 0 .. 2**4 - 1 with Size => 4; > > type Baud_Rate_Register is > record > DIV_Fraction : Fraction; > DIV_Mantissa : Mantissa; > end record with Size => 32; > for Baud_Rate_Register use > record > DIV_Fraction at 0 range 0 .. 3; > DIV_Mantissa at 0 range 4 .. 15; > end record; > > If I write > USART2.BRR.DIV_Mantissa := 16#445#; > USART2.BRR.DIV_Fraction := 16#c#; > A memory dump shows the final content to be 0x00005c5c whereas > intermediary result was 0x00004450 as expected. > n the other hand, if I write > USART2.BRR := Baud_Rate_Register'(DIV_Mantissa => 16#445#, > DIV_Fraction => 16#c#); > > There is no problem, the final content is 0x0000445c as expected. > > Did someone experience such kind of behaviour with STM32 class micro- > controllers ? Look at the generated assembly code for the first example with objdump; I suspect you will find there are load and/or store by byte references in there. Given the hardware restrictions on the size of accesses to the registers that will cause Bad Things (TM) to happen. Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world