Nп/п : 75 из 100
 От   : Randy Brukardt                      2:5075/128        27 сен 23 22:27:41
 К    : Niklas Holsti                                         27 сен 23 06:31:02
 Тема : Re: Valid attribute and input operations
----------------------------------------------------------------------------------
                                                                                 
@MSGID: 1@dont-email.me> 6c229616
@REPLY: <knff56Fdjg6U1@mid.individual.net>
bec98834
@REPLYADDR Randy Brukardt <randy@rrsoftware.com>
@REPLYTO 2:5075/128 Randy Brukardt
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: 1@dont-email.me>
@RFC-References:
<22930fd1-c7ff-46cf-8c75-892212afa85en@googlegroups.com> 1@dont-email.me> 1@dont-email.me>
<knff56Fdjg6U1@mid.individual.net>
@TZUTC: -0500
@TID: FIDOGATE-5.12-ge4e8b94
No, the specified representation is always used when storing to memory (with 
the single exception of loop parameters, which cannot have address clauses 
or other representation specifications). I think even enum parameters are 
written in the representation. However, any time an enumeration value is 
read into a register it is converted to a position number. Usually, such 
values are used in indexing, comparing, or an attribute like `Pos or `Succ, 
all of which are defined to work on position numbers. But if you simply 
assign the value out again, it will get converted both ways. We do have an 
optimization to remove pairs of TOREP/DEREP, but not the reverse since 
Program_Error is a possibility from DEREP. (Well, unless unsafe 
optimizations are on, but I don`t recommend using those for the obvious 
reasons.)

                              Randy.


"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:knff56Fdjg6U1@mid.individual.net...
> On 2023-09-26 9:13, Randy Brukardt wrote:
>
>> ... for Janus/Ada, enumeration types with specified representations
>> operate internally on the position numbers
>
>
> Hm, that`s interesting. Is that also the representation for record 
> components of such an enumerated type?
>
> For example, if I have:
>
>    type Command is (Off, On) with Size => 4;
>    for Command use (Off => 2, On => 5);
>    type Two_Commands is record
>       C1, C2: Command;
>    end record
>    with Pack, Size => 8;
>
>    TwoC : Two_Commands := (C1 => On, C2 => Off);
>
> will the record components (in memory) have the values C1 = 1 and C2 = 0 
> (position numbers) or C1 = 5, C2 = 2 (specified representation)?
>
> If they are represented by position numbers in the record, many if not 
> most of my embedded Ada programs would fail if compiled with Janus/Ada, 
> because the record values stored in I/O control registers or accessed via 
> DMA would be wrong.
>
> Damn, I thought those programs were not so compiler-dependent :-(



--- Microsoft Outlook Express 6.00.2900.5931
 * Origin: A noiseless patient Spider (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх